Last active
December 28, 2021 02:51
-
-
Save saippuakauppias/3430432 to your computer and use it in GitHub Desktop.
git shortcuts + zshrc
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
function git_current_branch () { | |
local ref | |
ref="$(git symbolic-ref --quiet HEAD 2>/dev/null)" | |
local ret=$? | |
if [[ $ret != 0 ]] | |
then | |
[[ $ret == 128 ]] && return 0 | |
ref=$(git rev-parse --short HEAD 2>/dev/null) || return 0 | |
fi | |
echo "${ref#refs/heads/}" | |
} | |
function git_main_branch () { | |
command git rev-parse --git-dir &> /dev/null || return | |
local branch | |
for branch in main trunk | |
do | |
if command git show-ref -q --verify refs/heads/$branch | |
then | |
echo $branch | |
return | |
fi | |
done | |
echo master | |
} | |
alias g='git' | |
alias gst='git status' | |
alias gc='git commit -a -m' | |
alias gcd='git checkout' | |
alias gcm='git checkout $(git_main_branch)' | |
alias gb='git branch' | |
alias glg='git log --stat --max-count=5' | |
alias ga='git add .' | |
alias gd='git diff' | |
alias gds='git diff --staged' | |
alias ggpull='git pull origin $(git_current_branch)' | |
alias ggpush='git push origin $(git_current_branch)' | |
alias gf='git fetch' | |
# see also: ~/.oh-my-zsh/plugins/git/git.plugin.zsh | |
export ZPLUG_HOME=/usr/local/opt/zplug | |
source $ZPLUG_HOME/init.zsh | |
zplug "plugins/colored-man-pages", from:oh-my-zsh | |
# в основном добавляют автодополнение для команд | |
zplug "plugins/docker-compose", from:oh-my-zsh | |
zplug "plugins/docker", from:oh-my-zsh | |
zplug "plugins/brew", from:oh-my-zsh | |
if command -v pyenv 1>/dev/null 2>&1; then | |
eval "$(pyenv init -)" | |
fi | |
eval "$(direnv hook zsh)" | |
alias ll="ls -la" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment