app-shells/bashrc: Do window title setup through PS1 #223641 by michael@smith-li...
authorMike Frysinger <vapier@gentoo.org>
Tue, 24 Feb 2015 20:58:48 +0000 (20:58 +0000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 26 Jan 2016 07:12:10 +0000 (02:12 -0500)
app-shells/bash/files/bashrc

index 300070974f5479d959ff8bd4977eb6fe16973ac5..6622b84eb71d58535fbc2b86cfbde4cef52df9ee 100644 (file)
@@ -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