Last active
November 22, 2019 13:40
-
-
Save dougbacelar/0802a1a96f9ccae67afb55b5c83ffcc8 to your computer and use it in GitHub Desktop.
.bashrc file to add the git branch to the command line and git command aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -f ~/.bashrc ]; then | |
. ~/.bashrc | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### DISPLAY GIT BRANCH NAME WITH COLORS | |
Cyan="\[\033[0;36m\]" # Cyan | |
Green="\[\033[0;32m\]" # Green | |
White="\[\033[0;37m\]" # White | |
clear # removes the last logged in message | |
find_git_branch() { | |
# Based on: http://stackoverflow.com/a/13003854/170413 | |
local branch | |
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then | |
if [[ "$branch" == "HEAD" ]]; then | |
branch='detached*' | |
fi | |
git_branch="($branch)" | |
else | |
git_branch="" | |
fi | |
echo $git_branch | |
} | |
export PS1="$Green \w $Cyan\$(find_git_branch)$White $ " | |
#export PS1="\$Green\w \$(find_git_branch)\$Cyan $ " | |
##### | |
##### GIT ALIASES | |
alias newbranch='function _newBranch(){ [ -z "$1" ] && return 1; echo "git checkout -b $1"; git checkout -b $1; echo "git push -u origin $1"; git push -u origin $1; };_newBranch' | |
alias deletebranch='function _deletebranch(){ [ -z "$1" ] && return 1; echo "git branch -D $1"; git branch -D $1; echo "git push origin -d $1"; git push origin -d $1; };_deletebranch' | |
alias gs='git status' | |
alias gp='git push' | |
alias gd='git diff' | |
##### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
save these files on the
~/
directory