I don't need full forgit, let's steal just the neede part.
This commit is contained in:
parent
f369e0ad3b
commit
5c8e7bcce9
4 changed files with 27 additions and 5 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -4,6 +4,3 @@
|
|||
[submodule "zsh/modules/zsh-syntax-highlighting"]
|
||||
path = zsh/modules/zsh-syntax-highlighting
|
||||
url = https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
[submodule "zsh/modules/forgit"]
|
||||
path = zsh/modules/forgit
|
||||
url = https://github.com/wfxr/forgit.git
|
||||
|
|
|
@ -26,10 +26,10 @@ if [ -f $XDG_CONFIG_HOME/fzf/fzf.zsh ]; then
|
|||
_fzf_compgen_dir() {
|
||||
fd -H -L --ignore-file $XDG_CONFIG_HOME/local/fd --type d . "$1"
|
||||
}
|
||||
source $ZDOTDIR/fzf-git.zsh
|
||||
fi
|
||||
|
||||
# plugins
|
||||
source $ZDOTDIR/modules/forgit/forgit.plugin.zsh
|
||||
source $ZDOTDIR/modules/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
|
||||
# theme
|
||||
|
|
26
zsh/fzf-git.zsh
Normal file
26
zsh/fzf-git.zsh
Normal file
|
@ -0,0 +1,26 @@
|
|||
# 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='ctrl-j:preview-up' --bind='ctrl-k: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
|
|
@ -1 +0,0 @@
|
|||
Subproject commit c63bd2b8d1f0fc97c5b54ee24c02e4274e1eca5f
|
Loading…
Add table
Add a link
Reference in a new issue