Created
December 16, 2024 22:33
-
-
Save giacaglia/5bbe31bb3b51404e17301cdabf2517dd to your computer and use it in GitHub Desktop.
This file contains 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
# ---------------------- | |
# Git Aliases | |
# ---------------------- | |
alias ga='git add' | |
alias gaa='git add .' | |
alias gaaa='git add --all' | |
alias gau='git add --update' | |
alias gb='git branch' | |
alias gbd='git branch --delete ' | |
alias gc='git commit' | |
alias gcm='git commit --message' | |
alias gcf='git commit --fixup' | |
alias gco='git checkout' | |
alias gcob='git checkout -b' | |
alias gcom='git checkout master' | |
alias gcos='git checkout staging' | |
alias gcod='git checkout develop' | |
alias gd='git diff' | |
alias gda='git diff HEAD' | |
alias gi='git init' | |
alias glg='git log --graph --oneline --decorate --all' | |
alias gld='git log --pretty=format:"%h %ad %s" --date=short --all' | |
alias gm='git merge --no-ff' | |
alias gma='git merge --abort' | |
alias gmc='git merge --continue' | |
alias gp='git pull' | |
alias gpr='git pull --rebase' | |
alias gr='git rebase' | |
alias gs='git status' | |
alias gss='git status --short' | |
alias gst='git stash' | |
alias gsta='git stash apply' | |
alias gstd='git stash drop' | |
alias gstl='git stash list' | |
alias gstp='git stash pop' | |
alias gsts='git stash save' | |
COLOR_RED="\033[0;31m" | |
COLOR_YELLOW="\033[0;33m" | |
COLOR_GREEN="\033[0;32m" | |
COLOR_OCHRE="\033[38;5;95m" | |
COLOR_BLUE="\033[0;34m" | |
COLOR_WHITE="\033[0;37m" | |
COLOR_RESET="\033[0m" | |
function git_color { | |
local git_status="$(git status 2> /dev/null)" | |
if [[ ! $git_status =~ "working directory clean" ]]; then | |
echo -e $COLOR_RED | |
elif [[ $git_status =~ "Your branch is ahead of" ]]; then | |
echo -e $COLOR_YELLOW | |
elif [[ $git_status =~ "nothing to commit" ]]; then | |
echo -e $COLOR_GREEN | |
else | |
echo -e $COLOR_OCHRE | |
fi | |
} | |
# Git branch in prompt. | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p' | |
} | |
COLOR_DEF='%f' | |
COLOR_USR='%F{243}' | |
COLOR_DIR='%F{197}' | |
COLOR_GIT='%F{39}' | |
NEWLINE=$'\n' | |
setopt PROMPT_SUBST | |
export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% ' | |
if [ -f ~/.git-completion.bash ]; then | |
. ~/.git-completion.bash | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment