Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.