Skip to content

Instantly share code, notes, and snippets.

@mbenford
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbenford/25b01027c6860ea8c5f7 to your computer and use it in GitHub Desktop.
Save mbenford/25b01027c6860ea8c5f7 to your computer and use it in GitHub Desktop.
My .bashrc file
alias la="ls -a"
alias psa="ps aux"
GREEN="\[\e[0;32m\]"
RED="\[\e[0;31m\]"
LIGHTBLUE="\[\e[1;34m\]"
COLOREND="\[\e[00m\]"
git_branch_info() {
local branch_info=$(__git_ps1)
if [ ! "${branch_info}" == "" ]; then
if [ "$(git status --porcelain 2> /dev/null)" == "" ]; then
branch_info=${GREEN}${branch_info}${COLOREND}
else
branch_info=${RED}${branch_info}${COLOREND}
fi
local remote_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null)
if [ ! "${remote_branch}" == "" ]; then
local ahead_count=$(git rev-list --count $remote_branch..HEAD)
if [ $ahead_count -gt 0 ]; then
branch_info=${branch_info/)/:${ahead_count})}
fi
fi
fi
echo $branch_info
}
prompt() {
local working_dir="${LIGHTBLUE}\w${COLOREND}"
local suffix="${LIGHTBLUE}\$${COLOREND} "
PS1="${working_dir}$(git_branch_info)${suffix}"
# Sets the terminal title as the current directory
printf "\e]2;${PWD/$HOME/\~}\a";
}
[[ -s "$HOME/.bash_aliases" ]] && source "$HOME/.bash_aliases"
[[ -s "$HOME/.bash_prompt" ]] && source "$HOME/.bash_prompt"
bind TAB:menu-complete
export PROMPT_COMMAND=prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment