From ff48d0ee694bce4e945c5839faa2f70fc4ca5729 Mon Sep 17 00:00:00 2001 From: "John Ankarstr\\xf6m" Date: Sat, 5 Jun 2021 16:23:31 +0200 Subject: 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. --- etc/shrc | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 9 deletions(-) (limited to 'etc/shrc') 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 -- cgit v1.2.3