Skip to content

Instantly share code, notes, and snippets.

@lambda-fairy
Last active December 20, 2015 14:09
Show Gist options
  • Save lambda-fairy/6144190 to your computer and use it in GitHub Desktop.
Save lambda-fairy/6144190 to your computer and use it in GitHub Desktop.
My .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# Include the default .bashrc
. /etc/skel/.bashrc
# Don't save command history on the VM
if [ "$(hostname)" == 'bonbon' ]; then
unset HISTFILE
fi
function supports_color {
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
return 0
else
return 1
fi
}
# Show the git branch
function parse_hostname {
case "$(hostname)" in
felicity)
echo ')';;
dawn)
echo ']';;
bonbon)
echo ':';;
*)
echo ' ';;
esac
}
function parse_git_dirty {
[ -n "$(git status --porcelain 2> /dev/null)" ] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ \1$(parse_git_dirty)/"
}
if supports_color; then
LIGHT_GRAY="\[\e[0;37m\]"
DIM_GRAY="\[\e[2;37m\]"
GREEN="\[\e[0;32m\]"
BLUE="\[\e[0;34m\]"
WHITE="\[\e[1;37m\]"
RESET="\[\e[m\]"
fi
TITLE_BEGIN="\[\e]0;"
TITLE_END="\a\]"
# Show the current directory in the title bar
if [ "$TERM" == 'xterm' ]; then
TITLEBAR="${TITLE_BEGIN}\w (\h)${TITLE_END}"
fi
PS1="${TITLEBAR}${GREEN} \w${BLUE}\$(parse_git_branch)${DIM_GRAY}${RESET} \$(parse_hostname) ${RESET}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment