I don't need these hacky aliases, I have tig.
This commit is contained in:
parent
f7828c268d
commit
a145e22b5b
1 changed files with 0 additions and 26 deletions
26
zsh/fzf.zsh
26
zsh/fzf.zsh
|
@ -9,29 +9,3 @@ _fzf_compgen_path() {
|
||||||
_fzf_compgen_dir() {
|
_fzf_compgen_dir() {
|
||||||
fd -H -L --ignore-file ~/.local/config/fd --type d . "$1"
|
fd -H -L --ignore-file ~/.local/config/fd --type d . "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# heavily inspired (and sometimes stolen from): https://github.com/wfxr/forgit.git
|
|
||||||
_am_i_git_repo() { git rev-parse --is-inside-work-tree >/dev/null; }
|
|
||||||
|
|
||||||
gl() {
|
|
||||||
_am_i_git_repo || return 1
|
|
||||||
files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*")
|
|
||||||
cmd="echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | cat"
|
|
||||||
g=(git log --graph --format='%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' --color=always "$@")
|
|
||||||
fzf=(fzf --ansi --reverse --tiebreak=index --no-sort --bind='k:preview-up' --bind='j:preview-down' --bind="ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' |pbcopy)" --bind="enter:execute($cmd | LESS='-r' less)" --preview 'f() { set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}"); [ $# -eq 0 ] || git show --color=always $1; }; f {}')
|
|
||||||
$g | $fzf
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
gd() {
|
|
||||||
_am_i_git_repo || return 1
|
|
||||||
extract="
|
|
||||||
sed 's/^.*] //' |
|
|
||||||
sed 's/.* -> //' |
|
|
||||||
sed -e 's/^\\\"//' -e 's/\\\"\$//'"
|
|
||||||
files=$(git -c color.status=always -c status.relativePaths=true status -su | grep -F -e "$changed" -e "$unmerged" -e "$untracked" | sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/' | fzf --reverse --tiebreak=index --no-sort --bind='ctrl-j:preview-up' --bind='ctrl-k:preview-down' --preview '(git diff --color=always -- {-1} | sed 1,4d; cat {-1})' | sh -c "$extract")
|
|
||||||
[[ -n "$files" ]] && echo "$files"| tr '\n' '\0' |xargs -0 -I% git add % && git status -su && return
|
|
||||||
echo 'Nothing to add.'
|
|
||||||
}
|
|
||||||
alias ga=gd
|
|
||||||
alias gs=gd
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue