Enrico Boldori / Wiki

« Go back ⤓ Download

Linux - .bashrc.txt

# --------------------------------------------------
# PS1 variable customization
# --------------------------------------------------

# The original __git_ps1 helper can be really slow.
# As we are interested in only the branch name, this approach is much faster
# We also do it only if a .git folder exists
parse_git_branch() {
	[ -d ".git" ] && git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

PS1_1='\n${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\H\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]'
#PS1_2='$(__git_ps1 " (%s)")'
PS1_2='$(parse_git_branch)'
PS1_3='\n\$ '

PS1="${PS1_1}${PS1_2}${PS1_3}"
# --------------------------------------------------

# Save history after each command
PROMPT_COMMAND='history -a'

# Add timestamps to the command history
export HISTTIMEFORMAT="%y-%m-%d %T "

# Unlimited history!
HISTSIZE=
HISTFILESIZE=