Skip to content

Commit

Permalink
chore: change git aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
bobstrange committed May 9, 2024
1 parent 9b2aa0e commit 39fa5f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
13 changes: 9 additions & 4 deletions tag-zsh/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ alias ln='ln -v'
alias mkdir='mkdir -p'
# alias tig='tig --all'

# # Git
# alias gad='git add'
# alias gcm='git commit -m'
# alias gsw='git switch'
# Git
alias gad=fz-git-add
alias gbr=fz-git-branch
alias gco=fz-git-checkout
alias gsh=fz-git-show
alias gdel=fz-git-delte-branch
alias gsta=fz-git-stash-apply
alias gcm='git commit -m'
alias gsw='git switch'

# Pretty print the path
alias path='echo $PATH | tr -s ":" "\n"'
Expand Down
12 changes: 6 additions & 6 deletions tag-zsh/zsh/configs/fzf.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1"
_viewGitLogLine="$_gitLogLineToHash | xargs -I % sh -c 'git show --color=always % | diff-so-fancy'"

# git commit browser with previews
gshow() {
fz-git-show() {
glNoGraph |
fzf --no-sort --reverse --tiebreak=index --no-multi \
--ansi --preview="$_viewGitLogLine" \
Expand All @@ -36,7 +36,7 @@ gshow() {
}

# checkout git branch (including remote branches), sorted by most recent commit, limit 30 last branches
gbr() {
fz-git-branch() {
local branches branch
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
branch=$(echo "$branches" |
Expand All @@ -47,7 +47,7 @@ gbr() {
}

# checkout git commit with previews
gco() {
fz-git-checkout() {
local commit
commit=$( glNoGraph |
fzf --no-sort --reverse --tiebreak=index --no-multi \
Expand All @@ -58,15 +58,15 @@ gco() {
}

# delete git branches
gdel() {
fz-git-delete-branch() {
local branches delete_branches
branches=$(git --no-pager branch | grep -vE '(main|master|development)')
delete_branches=$(echo "$branches" | fzf --multi)
echo "$delete_branches" | sed "s/.* //" | xargs git branch -D
}

# git add with previews
gad() {
fz-git-add() {
git ls-files --deleted --modified --other --exclude-standard | \
fzf \
--multi \
Expand All @@ -75,7 +75,7 @@ gad() {
}

# git stash apply with previews
gsta() {
fz-git-stash-apply() {
git stash list | \
fzf \
--exit-0 \
Expand Down

0 comments on commit 39fa5f2

Please sign in to comment.