summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-12-07 12:42:39 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-12-07 12:42:39 -0500
commit2aeb4cce82448d0216411fb8a0b6676f5e87d7da (patch)
treea75ff0f58deff2c63506665c9d93b5b6d1d76d99
parent9af5f9a09be1a755630c4c9f3cf99e93da65c285 (diff)
bash: rename the buffer in Emacs' ansi-term
-rw-r--r--.config/bash/rc.d/emacs.sh20
-rw-r--r--.config/bash/rc.sh2
2 files changed, 21 insertions, 1 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
diff --git a/.config/bash/rc.sh b/.config/bash/rc.sh
index 633f81e..62cc8ec 100644
--- a/.config/bash/rc.sh
+++ b/.config/bash/rc.sh
@@ -23,7 +23,6 @@ mkdir -p "${HISTFILE%/*}"
# General settings
shopt -s checkwinsize # update the values of LINES and COLUMNS
shopt -s globstar # Let ** recursively scan directories
-PROMPT_COMMAND=''
################################################################################
# Overly complicated setting of PS1 #
@@ -38,6 +37,7 @@ term-title() {
esac
printf "$fmt" "$*"
}
+PROMPT_COMMAND=''
make_prompt() {
echo "${BOLD}${GREEN}\u@\h${BLUE}:\w${RESET}"