+
+##################
+# Editor aliases #
+##################
+
+if emacsclient --version &> /dev/null; then
+ export ALTERNATE_EDITOR='vim'
+ export EDITOR='emacsclient --tty'
+
+ if [[ "$TERM" == screen* ]]; then
+ aliasf edit 'emacsclient --tty'
+ else
+ aliasf edit 'emacsclient --create-frame --no-wait'
+ fi
+else
+ export EDITOR='vim'
+ aliasf edit 'vim'
+fi
+
+
+#########################
+# Optional local config #
+#########################
+
+[ -r ~/.bashrc_local ] && source ~/.bashrc_local
+
+
+##################
+# xterm titlebar #
+##################
+
+# When at a prompt display `hostname:workingdir`
+function print_title_prompt {
+ echo -ne "\\033]0;$(hostname|cut -d. -f1):${PWD/$HOME/\~}\\007"
+
+ if [[ "$TERM" == screen* ]]; then
+ echo -ne '\033kbash\033\\'
+ fi
+}
+PROMPT_COMMAND=print_title_prompt
+
+# Display the command about to be executed
+# This must go at the end of bashrc to avoid running the trap on commands in the bashrc
+function print_title_exec {
+ [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return
+
+ echo -ne '\033]0;'
+ echo -n "$BASH_COMMAND" | tr -cd '[:graph:] '
+ echo -ne '\007'
+
+ if [[ "$TERM" == screen* ]]; then
+ echo -ne '\033k'
+ echo -n "$BASH_COMMAND" | \
+ sed 's/^sudo //' | \
+ cut -d' ' -f1 | \
+ tr -cd '[:graph:]'
+ echo -ne '\033\\'
+ fi
+}
+trap print_title_exec DEBUG
+
+