aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLAN-TW <lantw44@gmail.com>2013-11-03 00:45:14 +0800
committerLAN-TW <lantw44@gmail.com>2013-11-03 00:45:14 +0800
commit4b2d32e6cacca93f68fdfd60f7ce531611d1c97f (patch)
tree33c28bf19d59ccedf968c4cc6fcc613f6700934e
parentb5df9316ab3280ad9a8bbbbc4de277b3665959f1 (diff)
downloadconfigfile-4b2d32e6cacca93f68fdfd60f7ce531611d1c97f.tar
configfile-4b2d32e6cacca93f68fdfd60f7ce531611d1c97f.tar.gz
configfile-4b2d32e6cacca93f68fdfd60f7ce531611d1c97f.tar.bz2
configfile-4b2d32e6cacca93f68fdfd60f7ce531611d1c97f.tar.lz
configfile-4b2d32e6cacca93f68fdfd60f7ce531611d1c97f.tar.xz
configfile-4b2d32e6cacca93f68fdfd60f7ce531611d1c97f.tar.zst
configfile-4b2d32e6cacca93f68fdfd60f7ce531611d1c97f.zip
bash_include: 顯示終端機裝置號碼README-20131104
-rw-r--r--bash_include21
1 files changed, 18 insertions, 3 deletions
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