1 # ~/.bashrc: executed by bash(1) for non-login shells.
2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
5 # don't put duplicate lines or lines starting with space in the history.
6 # See bash(1) for more options
9 # append to the history file, don't overwrite it
12 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
16 # check the window size after each command and, if necessary,
17 # update the values of LINES and COLUMNS.
20 if [ -f ~/.bash_aliases ]; then
25 # enable programmable completion features (you don't need to enable
26 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
27 # sources /etc/bash.bashrc).
28 if ! shopt -oq posix; then
29 if [ -f /usr/share/bash-completion/bash_completion ]; then
30 . /usr/share/bash-completion/bash_completion
31 elif [ -f /etc/bash_completion ]; then
32 . /etc/bash_completion
39 YELLOW=$(tput setaf 3)
41 MAGENTA=$(tput setaf 5)
47 function __virtualenv_prompt() {
48 if [ -n "$VIRTUAL_ENV" ]; then
49 echo "(${VIRTUAL_ENV##*/}) "
53 # set up command prompt
54 function __prompt_command()
56 # capture the exit status of the last command
60 # check if inside git repo
61 local git_status="`git status -unormal 2>&1`"
62 if git rev-parse --git-dir > /dev/null 2>&1; then
63 git_status=$(git status --porcelain)
64 # parse the porcelain output of git status
65 if [[ ! $git_status = *[![:space:]]* ]]; then
67 elif [[ $git_status =~ ^\?\? ]]; then
73 branch=$(git symbolic-ref -q HEAD)
74 branch=${branch##refs/heads/}
75 branch=${branch:-HEAD}
77 # add the result to prompt
78 PS1+="\n\[$Color_On\][$branch]\[$RESET\]\n"
82 PS1+="$(__virtualenv_prompt)"
84 if [ $EXIT -eq 0 ]; then PS1+="\[$GREEN\][\!]\[$RESET\] "; else PS1+="\[$RED\][\!]\[$RESET\] "; fi
86 # if logged in via ssh shows the ip of the client
87 if [ -n "$SSH_CLIENT" ]; then
89 PS1+="\[$YELLOW\]("$IP")\[$RESET\]";
92 # debian chroot stuff (take it or leave it)
93 PS1+="${debian_chroot:+($debian_chroot)}"
95 # basic information (user@host:path)
96 PS1+="\[$RED$BOLD\]\u\[$RESET\]@\[$RED$BOLD\]\h\[$RESET\]:\[$BLUE\]\w\[$RESET\]\n"
99 # prompt $ or # for root
102 PROMPT_COMMAND=__prompt_command
104 if ! pgrep -x -u "${USER}" gpg-agent >/dev/null 2>&1; then
105 gpg-connect-agent /bye >/dev/null 2>&1
109 if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
110 export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
113 export GPG_TTY=($tty)
114 gpg-connect-agent updatestartuptty /bye > /dev/null
117 export TMPDIR="/tmp/${USER}"
118 eval `dircolors ~/.dir_colors`