aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorJohn Ankarstr\xf6m <john@ankarstrom.se>2021-06-05 16:23:31 +0200
committerJohn Ankarstr\xf6m <john@ankarstrom.se>2021-06-05 16:23:31 +0200
commitff48d0ee694bce4e945c5839faa2f70fc4ca5729 (patch)
treeaa822fac0239257f7bc556ef41d8750e51306691 /etc
parentf5f2ad88816559523f3dfe106969da60386ec1b0 (diff)
downloadlbsd-ff48d0ee694bce4e945c5839faa2f70fc4ca5729.tar.gz
shrc: Set command title in bash only for non-builtins
... as well as some other common commands. Note the eval statement, which is necessary in order to keep compatibility with other shells than bash.
Diffstat (limited to 'etc')
-rw-r--r--etc/shrc88
1 files changed, 79 insertions, 9 deletions
diff --git a/etc/shrc b/etc/shrc
index 29c34ac..e637857 100644
--- a/etc/shrc
+++ b/etc/shrc
@@ -23,20 +23,90 @@ case "$-" in *i*)
*ksh,*,/*)
PS1=$PS1']0;$PWD' ;;
*bash,screen,*)
- PROMPT_COMMAND='safetitle "${PWD/#\/home\/john/\~}"'
- cmdtitle() {
- case "$BASH_COMMAND" in
- safetitle*) ;;
- *) safetitle "$BASH_COMMAND" ;;
- esac
- } ;;
+ PROMPT_COMMAND='safetitle "${PWD/#\/home\/john/\~}"' ;;
*bash,*,/*)
- PS1='\[\033]0;\w\007\]'$PS1
- cmdtitle() { echo -ne "\033]0;$BASH_COMMAND\007"; } ;;
+ PS1='\[\033]0;\w\007\]'$PS1 ;;
*)
;;
esac
+ case "$0" in *bash)
+ cmdtitle() {
+ cmd=${BASH_COMMAND#builtin }
+ cmd=${cmd#doas }
+ case "${cmd%% *}" in
+ safetitle) return ;;
+ screen) return ;;
+ ls) return ;;
+ ll) return ;;
+ mv) return ;;
+ rm) return ;;
+ :) return ;;
+ .) return ;;
+ source) return ;;
+ alias) return ;;
+ bg) return ;;
+ bind) return ;;
+ break) return ;;
+ builtin) return ;;
+ caller) return ;;
+ cd) return ;;
+ command) return ;;
+ compgen) return ;;
+ complete) return ;;
+ compopt) return ;;
+ continue) return ;;
+ declare) return ;;
+ typeset) return ;;
+ disown) return ;;
+ echo) return ;;
+ enable) return ;;
+ eval) return ;;
+ exec) return ;;
+ exit) return ;;
+ export) return ;;
+ fc) return ;;
+ fc) return ;;
+ fg) return ;;
+ getopts) return ;;
+ hash) return ;;
+ help) return ;;
+ history) return ;;
+ jobs) return ;;
+ kill) return ;;
+ let) return ;;
+ local) return ;;
+ mapfile) return ;;
+ readarray) return ;;
+ popd) return ;;
+ printf) return ;;
+ pushd) return ;;
+ pwd) return ;;
+ read) return ;;
+ readonly) return ;;
+ return) return ;;
+ set) return ;;
+ shift) return ;;
+ shopt) return ;;
+ suspend) return ;;
+ test) return ;;
+ [) return ;;
+ trap) return ;;
+ type) return ;;
+ ulimit) return ;;
+ umask) return ;;
+ unalias) return ;;
+ unset) return ;;
+ wait) return ;;
+ *) ;;
+ esac
+ eval 'pwd=${PWD/\/home\/john/\~}'
+ [[ $TERM = screen ]] &&
+ safetitle "$BASH_COMMAND ($pwd)" ||
+ echo -ne "\033]0;$BASH_COMMAND ($pwd)\007"
+ }
+ ;; esac
+
# This file is used by shells that might not support
# set -o tabcomplete, so check before trying to use it.
( set -o tabcomplete 2>/dev/null ) && set -o tabcomplete