summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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}"