GoWiki
Index
Sections
Search
Login
ston1th
Git Functions
# Git Functions ``` status() { git status; } fetch() { git fetch origin ${@} >/dev/null 2>&1; } lsb() { git branch; } git_branch() { lsb 2>/dev/null|awk "/^*/{print \"${1}\"\$2}"; } pull() { git pull ${1-origin} $(git_branch); } push() { git push origin $(git_branch); } commit() { git commit -m "${1}" && push; } commitb() { commit "$(git_branch) ${1}"; } checkout() { git checkout ${@}; } master() { checkout master; pull; } branch() { [ "${1}" == "" ] && { echo "error no branch name given">&2; return 1; }; [ "$(git_branch)" == "master" ] && pull || master; fetch; git branch -a|grep ${1}>/dev/null 2>&1 && { fetch "${1}:${1}"; checkout "${1}"; } || c heckout -b "${1}"; } del() { [ "${1}" == "" ] && b=$(git_branch) || b="${1}"; [ "${b}" == "master" ] && { echo "error branch master can not be deleted">&2; return 1; } || { master; git branch -D "${b}"; }; } ``` # PS1 ``` RED='\[\e[0;31m\]';REDB='\[\e[1;31m\]' GRN='\[\e[0;32m\]';GRNB='\[\e[1;32m\]' YLW='\[\e[0;33m\]';YLWB='\[\e[1;33m\]' BLU='\[\e[0;34m\]';BLUB='\[\e[1;34m\]' MGN='\[\e[0;35m\]';MGNB='\[\e[1;35m\]' CYN='\[\e[0;36m\]';CYNB='\[\e[1;36m\]' GRY='\[\e[0;37m\]';NON='\[\e[00m\]' export PS1="${CYN}[\u@\h\$(git_branch \" \") ${NON}\W${CYN}]\$${NON} " ```