From 0345ae2961b2c64b177043d54c39222278ca71bd Mon Sep 17 00:00:00 2001 From: Andrew Coleman Date: Tue, 9 Feb 2021 10:33:23 -0500 Subject: [PATCH] set history -a in PROMPT_COMMAND when using __git_ps1. add some functions to change window titles and revert after using ssh/su. add an emoji showing a host is a _remote_ host when using ssh to connect to another machine. --- .bashrc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index 47d328c..51d5ce0 100644 --- a/.bashrc +++ b/.bashrc @@ -65,7 +65,10 @@ else GIT_PS1_SHOWUPSTREAM="auto" GIT_PS1_SHOWCOLORHINTS=1 GIT_PS1_HIDE_IF_PWD_IGNORED=1 - PROMPT_COMMAND='__git_ps1 "\[\033[01;32m\][\u@\h\[\033[01;34m\] \w\[\033[01;32m\]]\[\033[00m\]" "\\\$ "' + if [[ -n $SSH_CLIENT ]] ; then + SSH_CHAR="📡" + fi + PROMPT_COMMAND='history -a; __git_ps1 "\[\033[01;32m\][\u@\h${SSH_CHAR}\[\033[01;34m\] \w\[\033[01;32m\]]\[\033[00m\]" "\\\$ "' else PS1='\[\033[01;32m\][\u@\h\[\033[01;34m\] \w\[\033[01;32m\]]\[\033[00m\]\$ ' fi @@ -110,4 +113,24 @@ ex () fi } +# change the title of the current window or tab +title() +{ + echo -ne "\033]0;$*\007" +} + +ssh() +{ + echo -ne '\e[22t' + /usr/bin/ssh "$@" + echo -ne '\e[23t' +} + +su() +{ + echo -ne '\e[22t' + /bin/su "$@" + echo -ne '\e[23t' +} + [[ -e $HOME/.bash.local ]] && . $HOME/.bash.local || true