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 # If not running interactively, don't do anything
11 # don't put duplicate lines or lines starting with space in the history.
12 # See bash(1) for more options
13 HISTCONTROL=ignoreboth
15 # append to the history file, don't overwrite it
18 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
22 # check the window size after each command and, if necessary,
23 # update the values of LINES and COLUMNS.
26 # make less more friendly for non-text input files, see lesspipe(1)
27 if [ -x /usr/bin/lesspipe ]; then
28 export LESSOPEN="|lesspipe %s"
29 elif [ -x /usr/bin/lesspipe.sh ]; then
30 export LESSOPEN="|lesspipe %s"
33 # set variable identifying the chroot you work in (used in the prompt below)
34 if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
35 debian_chroot=$(cat /etc/debian_chroot)
39 # colored GCC warnings and errors
40 export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
43 if [ -f ~/.bash_aliases ]; then
47 eval `dircolors ~/.dir_colors`
49 # enable programmable completion features (you don't need to enable
50 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
51 # sources /etc/bash.bashrc).
52 if ! shopt -oq posix; then
53 if [ -f /usr/share/bash-completion/bash_completion ]; then
54 . /usr/share/bash-completion/bash_completion
55 elif [ -f /etc/bash_completion ]; then
56 . /etc/bash_completion
63 YELLOW=$(tput setaf 3)
65 MAGENTA=$(tput setaf 5)
71 function __virtualenv_prompt() {
72 if [ -n "$VIRTUAL_ENV" ]; then
73 echo "(${VIRTUAL_ENV##*/}) "
77 # set up command prompt
78 function __prompt_command()
80 # capture the exit status of the last command
84 # check if inside git repo
85 local git_status="`git status -unormal 2>&1`"
86 if git rev-parse --git-dir > /dev/null 2>&1; then
87 git_status=$(git status --porcelain)
88 # parse the porcelain output of git status
89 if [[ ! $git_status = *[![:space:]]* ]]; then
91 elif [[ $git_status =~ ^\?\? ]]; then
97 branch=$(git symbolic-ref -q HEAD)
98 branch=${branch##refs/heads/}
99 branch=${branch:-HEAD}
101 # add the result to prompt
102 PS1+="\n\[$Color_On\][$branch]\[$RESET\]\n"
106 PS1+="$(__virtualenv_prompt)"
108 if [ $EXIT -eq 0 ]; then PS1+="\[$GREEN\][\!]\[$RESET\] "; else PS1+="\[$RED\][\!]\[$RESET\] "; fi
110 # if logged in via ssh shows the ip of the client
111 if [ -n "$SSH_CLIENT" ]; then
113 PS1+="\[$YELLOW\]("$IP")\[$RESET\]";
116 # debian chroot stuff (take it or leave it)
117 PS1+="${debian_chroot:+($debian_chroot)}"
119 # basic information (user@host:path)
120 PS1+="\[$RED$BOLD\]\u\[$RESET\]@\[$RED$BOLD\]\h\[$RESET\]:\[$BLUE\]\w\[$RESET\]\n"
123 # prompt $ or # for root
126 PROMPT_COMMAND=__prompt_command
128 if ! pgrep -x -u "${USER}" gpg-agent >/dev/null 2>&1; then
129 gpg-connect-agent /bye >/dev/null 2>&1
133 if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
134 export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
137 export GPG_TTY=($tty)
138 gpg-connect-agent updatestartuptty /bye > /dev/null