diff options
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 |