diff options
-rw-r--r-- | .config/bash/rc.d/emacs.sh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/.config/bash/rc.d/emacs.sh b/.config/bash/rc.d/emacs.sh index 32ed654..9c1bf4d 100644 --- a/.config/bash/rc.d/emacs.sh +++ b/.config/bash/rc.d/emacs.sh @@ -23,14 +23,18 @@ case "$TERM" in fi _EMACS_BUFFER="$(emacsclient -e "(with-current-buffer ${buffer} (rename-buffer ${name} t)))" 2>/dev/null)" } - _emacs_get_desired_buffer_name() { - local base=$PWD suffix='' - if [[ $base =~ /(src|pkg|doc|pkg-libre|src-libre|trunk|tags|branches)$ ]]; then + _emacs_get_short_cwd() { + local base=$1 + local suffix='' + if [[ $base =~ (/(src|pkg|doc|pkg-libre|src-libre|trunk|tags|branches))*$ ]]; then suffix=$BASH_REMATCH base=${base%$suffix} fi base=${base##*/} - echo "*ansi-term*<${base}${suffix}>" + echo ${base}${suffix} + } + _emacs_get_desired_buffer_name() { + echo "*ansi-term*<$(_emacs_get_short_cwd "$PWD")>" } PROMPT_COMMAND='_emacs_rename_terminal "$(_emacs_get_desired_buffer_name)"' :;; |