Skip to content

Instantly share code, notes, and snippets.

@boblannon
Last active February 24, 2016 15:50
Show Gist options
  • Save boblannon/0b08094fa506b68ad371 to your computer and use it in GitHub Desktop.
Save boblannon/0b08094fa506b68ad371 to your computer and use it in GitHub Desktop.
bashrc_snippets
function tabtitle(){
REPO_NAME=`git rev-parse --show-toplevel 2> /dev/null | awk -F'/' '{print $NF}'`;
if [ -z "$REPO_NAME" ]
then
echo ""
else
echo "[$REPO_NAME] "
fi
}
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];$(tabtitle)${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
alias __git_ps1="git branch 2>/dev/null | grep '*' | sed 's/* \(.*\)/\1/'"
export PS1="\W \\$>\[$(tput sgr0)\]"
# terminal colors
Gray="\[\033[1;36m\]"
Red="\[\033[0;31m\]"
Green="\[\033[0;32m\]"
Color_Off="\[\033[0m\]"
Time12h="\T"
Time12a="\@"
PathShort="\w"
PathFull="\W"
NewLine="\n"
Jobs="\j"
export PS1=$Gray$PathShort'$(git branch &>/dev/null;\
if [ $? -eq 0 ]; then \
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \
if [ "$?" -eq "0" ]; then \
# @4 - Clean repository - nothing to commit
echo "'$Green'[$(__git_ps1)]"; \
else \
# @5 - Changes to working tree
echo "'$Red'{$(__git_ps1)}"; \
fi) '$Color_Off'\$ "; \
else \
# @2 - Prompt when not in GIT repo
echo " '$Color_Off'\$ "; \
fi)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment