Skip to content

Instantly share code, notes, and snippets.

@markandey
Created February 9, 2016 21:57
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 markandey/080cfd5680c9c3204468 to your computer and use it in GitHub Desktop.
Save markandey/080cfd5680c9c3204468 to your computer and use it in GitHub Desktop.
gitenv.sh
source ~/bin/git-prompt.sh
set_prompt () {
Last_Command=$? # Must come first!
Blue='\[\e[01;34m\]'
White='\[\e[01;37m\]'
Red='\[\e[01;31m\]'
Green='\[\e[01;32m\]'
Pink='\[\e[01;35m\]'
Reset='\[\e[00m\]'
FancyX='\342\234\227'
Checkmark='\342\234\223'
Arrorw='\342\207\211'
Sep=''$White'|'$White''
Reset='\[\e[00m\]'
INV="\[\033[7m\]"
Cyan='\[\e[01;36m\]'
# Add a bright white exit status for the last command
PS1=""
# If it was successful, print a green check mark. Otherwise, print
# a red X.
if [[ $Last_Command == 0 ]]; then
PS1=$PS1"$Green$Checkmark"
else
PS1=$PS1"$Red$FancyX"
fi
# If root, just print the host in red. Otherwise, print the current user
# and host in green.
if [[ $EUID == 0 ]]; then
PS1=$PS1"$Red\\h$Sep"
else
PS1=$PS1"$Blue\\h$Sep"
fi
PS1=$PS1"$Pink\w$Green$Arrorw$Cyan$(__git_ps1)$Reset$ "
}
PROMPT_COMMAND='set_prompt'
function gc(){
git commit -v
}
function s(){
git status
}
function sp(){
PROMPT_COMMAND=''
PS1='\u@\h:\w\$: '
}
function githelp(){
echo " "
echo " ----- GIT HELP ----- "
echo " "
echo "1. Undo last commit and stage files"
echo " $ git reset --soft HEAD~"
echo " "
echo "2. Rewrite histoty"
echo " $ git commit --amend "
echo " $ git rebase -i HEAD~3 "
echo " "
echo "3. Rebase current branch from upstream master"
echo " $ git pull --rebase upstream master"
echo " "
echo "4. Reset to upstream."
echo " $git checkout master && git fetch upstream && git reset --hard upstream/master "
echo ""
echo ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment