From da151067f5ed8cfa29ee6486ce9358e0fdd89850 Mon Sep 17 00:00:00 2001 From: "John Ankarstr\\xf6m" Date: Sat, 5 Jun 2021 14:42:46 +0200 Subject: shrc: Support bash --- etc/shrc | 29 ++++++++++++++++++++++++----- home/john/.bash_profile | 3 +++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 home/john/.bash_profile diff --git a/etc/shrc b/etc/shrc index c6aff47..29c34ac 100644 --- a/etc/shrc +++ b/etc/shrc @@ -7,15 +7,34 @@ ll(){ ls -lp ${1+"$@"}; } case "$-" in *i*) set -o emacs + PS1= /bin/test -z "${HOST}" && HOST="$(hostname)" - PS1=' '${HOST%%.*} + case "$SHELL" in + *bash) PS1=${HOST%%.*} ;; + *ksh) PS1=' '${HOST%%.*} ;; + *) PS1='${HOST%%.*}' ;; + esac /bin/test "$(whoami)" = root && PS1=$PS1'# ' || PS1=$PS1'$ ' - # change terminal title to working directory on prompt + # dynamically change terminal title case "$0,$TERM,$XTERM_SHELL" in - *ksh,screen,*) PS1=$PS1'$(safetitle "$PWD")' ;; - *ksh,*,/*) PS1=$PS1']0;$PWD' ;; - *) ;; + *ksh,screen,*) + PS1=$PS1'$(safetitle "$PWD")' ;; + *ksh,*,/*) + PS1=$PS1']0;$PWD' ;; + *bash,screen,*) + PROMPT_COMMAND='safetitle "${PWD/#\/home\/john/\~}"' + cmdtitle() { + case "$BASH_COMMAND" in + safetitle*) ;; + *) safetitle "$BASH_COMMAND" ;; + esac + } ;; + *bash,*,/*) + PS1='\[\033]0;\w\007\]'$PS1 + cmdtitle() { echo -ne "\033]0;$BASH_COMMAND\007"; } ;; + *) + ;; esac # This file is used by shells that might not support diff --git a/home/john/.bash_profile b/home/john/.bash_profile new file mode 100644 index 0000000..de6c2ee --- /dev/null +++ b/home/john/.bash_profile @@ -0,0 +1,3 @@ +. $HOME/.profile +. $HOME/.shrc +trap cmdtitle DEBUG -- cgit v1.2.3