diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-12-07 12:42:39 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-12-07 12:42:39 -0500 |
commit | 2aeb4cce82448d0216411fb8a0b6676f5e87d7da (patch) | |
tree | a75ff0f58deff2c63506665c9d93b5b6d1d76d99 /.config/bash/rc.d/emacs.sh | |
parent | 9af5f9a09be1a755630c4c9f3cf99e93da65c285 (diff) |
bash: rename the buffer in Emacs' ansi-term
Diffstat (limited to '.config/bash/rc.d/emacs.sh')
-rw-r--r-- | .config/bash/rc.d/emacs.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/.config/bash/rc.d/emacs.sh b/.config/bash/rc.d/emacs.sh index f484bbb..7e84651 100644 --- a/.config/bash/rc.d/emacs.sh +++ b/.config/bash/rc.d/emacs.sh @@ -4,5 +4,25 @@ case "$TERM" in EDITOR=$SELECTED_EDITOR VISUAL=$SELECTED_EDITOR export SELECTED_EDITOR EDITOR VISUAL + _set_buffer_name() { + local name="$*" + local name_esc="${name//\\/\\\\}" + name_esc="${name_esc//\"/\\\"}" + emacsclient -e " +(with-current-buffer (window-buffer (selected-window)) + (if (not (string= \"${name}\" (buffer-name))) + (rename-buffer (generate-new-buffer-name \"${name}\")))) +" &>/dev/null + } + _create_buffer_name() { + local base=$PWD 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}>" + } + PROMPT_COMMAND='_set_buffer_name "$(_create_buffer_name)"' :;; esac |