Skip to content

Instantly share code, notes, and snippets.

@theSage21
Created October 15, 2015 06:11
Show Gist options
  • Save theSage21/bae283502b67c6a2c939 to your computer and use it in GitHub Desktop.
Save theSage21/bae283502b67c6a2c939 to your computer and use it in GitHub Desktop.
My bashrc
alias l="ls"
alias ll="ls -l"
alias la="ls -a"
alias act="source env/bin/activate"
alias v="vim"
alias v3="virtualenv -p python3 env"
alias v2="virutalenv -p python2 env"
Blue='\[\e[01;34m\]'
White='\[\e[01;37m\]'
Red='\[\e[01;31m\]'
Green='\[\e[01;32m\]'
Reset='\[\e[00m\]'
FancyX='\342\234\227'
Checkmark='\342\234\223'
gitbranch() {
# FIND GIT BRANCH OF PWD
2> /dev/null 1> /dev/null git status
if [[ $? == 0 ]]; then # it is a git repo
branch=$(git status|grep On\ branch|awk '{print $3}')
echo $branch
fi
}
set_prompt () {
Last_Command=$? # Must come first!
# Add a bright white exit status for the last command
PS1="$White\$? "
# If it was successful, print a green check mark. Otherwise, print
# a red X.
if [[ $Last_Command == 0 ]]; then
PS1+="$Green$Checkmark "
else
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+="$Red\\h "
else
PS1+="$Green\\u "
fi
# Print the working directory and prompt marker in blue, and reset
# the text color to the default.
PS1+="$Blue\\w "
# git branch
PS1+="$Red$(gitbranch)$Reset \\\$"
}
PROMPT_COMMAND='set_prompt'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment