diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-02-11 18:12:44 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-02-11 18:12:44 -0500 |
commit | 37ed11e213fff1abd4c18c7359252c6adeb0101b (patch) | |
tree | 54321412af8643499ec27b3d43657f283ce12efa | |
parent | 293deaa5b441e6a14df1f4537c200187b955d745 (diff) |
bash/rc.d/emacs.sh: allow suffixes to be chained
-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)"' :;; |