feat(zsh): drop ohmyzsh+git for custom aliases
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
# set up Zsh completions with plugins
|
||||
# mattmc3/ez-compinit
|
||||
# completions
|
||||
zsh-users/zsh-completions kind:fpath path:src
|
||||
|
||||
# frameworks like oh-my-zsh are supported
|
||||
getantidote/use-omz # handle OMZ dependencies
|
||||
ohmyzsh/ohmyzsh path:lib # load OMZ's library
|
||||
ohmyzsh/ohmyzsh path:plugins/git
|
||||
|
||||
# popular fish-like plugins
|
||||
# fish-like plugins
|
||||
zsh-users/zsh-autosuggestions
|
||||
|
||||
@@ -12,11 +12,57 @@ alias dcp="docker compose ps --format 'table {{.Name}}\t{{.Ports}}'"
|
||||
# navigation
|
||||
alias cdgit='cd $GGROOT'
|
||||
|
||||
# git
|
||||
alias gpo="git push origin"
|
||||
gros() { git reset "origin/$(git_current_branch)" --soft }
|
||||
alias gcan="git commit -v --amend --no-edit"
|
||||
# git status/diff
|
||||
alias gst="git status"
|
||||
alias gd="git diff"
|
||||
alias gds="git diff --staged"
|
||||
alias gdup="git diff @{upstream}"
|
||||
alias glog="git log --oneline --decorate --graph"
|
||||
alias gloga="git log --oneline --decorate --graph --all"
|
||||
alias glogaa="git log --oneline --graph --all --pretty=format:\"%C(auto)%h %C(blue)(%aL/%cL)%C(auto)%(decorate) %s%Creset\""
|
||||
|
||||
# git staging/commit
|
||||
alias ga="git add"
|
||||
alias gc="git commit -v"
|
||||
alias gc!="git commit -v --amend"
|
||||
alias gcan="git commit -v --amend --no-edit"
|
||||
alias gcan!="git commit -v --all --no-edit --amend"
|
||||
alias grs="git restore"
|
||||
|
||||
# git branch/checkout
|
||||
alias gb="git branch"
|
||||
alias gco="git checkout"
|
||||
alias gcm='git checkout $(git_main_branch)'
|
||||
alias gsw="git switch"
|
||||
|
||||
# git fetch/pull/push
|
||||
alias gfa="git fetch --all --prune"
|
||||
alias gl="git pull"
|
||||
alias gp="git push"
|
||||
alias gpf="git push --force-with-lease"
|
||||
alias gpf!="git push --force"
|
||||
alias gpo="git push origin"
|
||||
|
||||
# git rebase
|
||||
alias grb="git rebase"
|
||||
alias grba="git rebase --abort"
|
||||
alias grbc="git rebase --continue"
|
||||
alias grbi="git rebase -i"
|
||||
grbm() { git rebase "$(git_main_branch)" }
|
||||
|
||||
# git merge
|
||||
alias gm="git merge"
|
||||
alias gma="git merge --abort"
|
||||
alias gmc="git merge --continue"
|
||||
|
||||
# git cherry-pick
|
||||
alias gcp="git cherry-pick"
|
||||
alias gcpa="git cherry-pick --abort"
|
||||
alias gcpc="git cherry-pick --continue"
|
||||
|
||||
# git stash/reset
|
||||
alias gstp="git stash pop"
|
||||
gros() { git reset "origin/$(git_current_branch)" --soft }
|
||||
|
||||
# ruff
|
||||
alias ruffme="ruff check --fix && ruff format"
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
# git helpers for aliases
|
||||
function git_current_branch {
|
||||
command git rev-parse --abbrev-ref HEAD 2>/dev/null
|
||||
}
|
||||
|
||||
function git_main_branch {
|
||||
command git rev-parse --git-dir &>/dev/null || return
|
||||
local ref
|
||||
for ref in refs/{heads,remotes/{origin,upstream}}/{main,master,trunk}; do
|
||||
if command git show-ref -q --verify "$ref"; then
|
||||
echo ${ref:t}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo main
|
||||
}
|
||||
|
||||
function tmux_attach {
|
||||
local tmux_running
|
||||
tmux_running=$(pgrep tmux)
|
||||
|
||||
Reference in New Issue
Block a user