commit:     aa0fc40cbad85c69d35c94ebbd98a81be78123af
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 20:58:48 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Jan 26 07:12:10 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aa0fc40c

app-shells/bashrc: Do window title setup through PS1 #223641 by michael <AT> 
smith-li.com.  Add history -a to PROMPT_COMMAND #517342 by Paweł Hajdan, Jr.. 
Add fix from upstream for variable declare weirdness.

 app-shells/bash/files/bashrc | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/app-shells/bash/files/bashrc b/app-shells/bash/files/bashrc
index 3000709..6622b84 100644
--- a/app-shells/bash/files/bashrc
+++ b/app-shells/bash/files/bashrc
@@ -20,16 +20,29 @@ fi
 # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
 shopt -s checkwinsize
 
-# Enable history appending instead of overwriting.  #139609
+# Disable completion when the input buffer is empty.  i.e. Hitting tab
+# and waiting a long time for bash to expand all of $PATH.
+shopt -s no_empty_cmd_completion
+
+# Enable history appending instead of overwriting when exiting.  #139609
 shopt -s histappend
 
+# Save each command to the history file as it's executed.  #517342
+# This does mean sessions get interleaved when reading later on, but this
+# way the history is always up to date.  History is not synced across live
+# sessions though; that is what `history -n` does.
+PROMPT_COMMAND='history -a'
+
 # Change the window title of X terminals 
 case ${TERM} in
        xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
-               PROMPT_COMMAND='echo -ne 
"\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
+               PS1='\[\033]0;\u@\h:\w\007\]'
                ;;
        screen*)
-               PROMPT_COMMAND='echo -ne 
"\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
+               PS1='\[\033k\u@\h:\w\033\\\]'
+               ;;
+       *)
+               unset PS1
                ;;
 esac
 
@@ -65,9 +78,9 @@ if ${use_color} ; then
        fi
 
        if [[ ${EUID} == 0 ]] ; then
-               PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
+               PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
        else
-               PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
+               PS1+='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
        fi
 
        #BSD#@export CLICOLOR=1
@@ -78,9 +91,9 @@ if ${use_color} ; then
 else
        if [[ ${EUID} == 0 ]] ; then
                # show root@ when we don't have colors
-               PS1='\u@\h \W \$ '
+               PS1+='\u@\h \W \$ '
        else
-               PS1='\u@\h \w \$ '
+               PS1+='\u@\h \w \$ '
        fi
 fi
 

Reply via email to