From 4b2d32e6cacca93f68fdfd60f7ce531611d1c97f Mon Sep 17 00:00:00 2001 From: LAN-TW Date: Sun, 3 Nov 2013 00:45:14 +0800 Subject: =?UTF-8?q?bash=5Finclude:=20=E9=A1=AF=E7=A4=BA=E7=B5=82=E7=AB=AF?= =?UTF-8?q?=E6=A9=9F=E8=A3=9D=E7=BD=AE=E8=99=9F=E7=A2=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_include | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'bash_include') diff --git a/bash_include b/bash_include index 06e8adc..2b9c63a 100644 --- a/bash_include +++ b/bash_include @@ -13,12 +13,27 @@ if [[ "$-" == *i* ]] ; then interactive_shell=1; fi [ "$interactive_shell" ] && echo "Running .bash_include" [ "$interactive_shell" ] && default_tty_setting="`stty -g`" - +[ "$interactive_shell" ] && TTY="`tty`" && \ + if [[ "$TTY" =~ "/dev/tty"[0-9]+ ]]; then + tty_short="#v${TTY:8}" + elif [[ "$TTY" == "/dev/tty"* ]]; then + tty_short="#${TTY:8}" + elif [[ "$TTY" == "/dev/pts"* ]]; then + tty_short="#p${TTY:9}" + elif [[ "$TTY" == "/dev/pty"* ]]; then + tty_short="#p${TTY:9}" + elif [[ "$TTY" == "/dev/hvc"* ]]; then + tty_short="#h${TTY:8}" + elif [[ "$TTY" == "/dev/console" ]]; then + tty_short="#c${TTY:12}" + else + unset tty_short + fi # Internal Variables -colorprompting='\[\e[1;31m\]\!\[\e[m\] [\[\e[1;33m\]\u\[\e[m\]@\[\e[1;32m\]\h\[\e[m\] \[\e[1;36m\]\w\[\e[m\]]' -nocolorprompting='\! [\u@\h \w]' +colorprompting='\[\e[1;31m\]\!\[\e[m\] \[\e[35m\]$tty_short\[\e[m\][\[\e[1;33m\]\u\[\e[m\]@\[\e[1;32m\]\h\[\e[m\] \[\e[1;36m\]\w\[\e[m\]]' +nocolorprompting='\! $tty_short[\u@\h \w]' if [ "$SSH_CONNECTION" ] then -- cgit v1.2.3