diff options
-rw-r--r-- | fzf-git/functions.sh | 52 | ||||
-rw-r--r-- | fzf-git/key-binding.zsh | 19 | ||||
-rw-r--r-- | nix-conf/home/includes/zsh.nix | 14 | ||||
-rw-r--r-- | setup-home.sh | 2 |
4 files changed, 10 insertions, 77 deletions
diff --git a/fzf-git/functions.sh b/fzf-git/functions.sh deleted file mode 100644 index c1f6fb7..0000000 --- a/fzf-git/functions.sh +++ /dev/null @@ -1,52 +0,0 @@ -# GIT heart FZF -# ------------- - -is_in_git_repo() { - git rev-parse HEAD > /dev/null 2>&1 -} - -fzf-down() { - fzf --height 50% "$@" --border -} - -_gf() { - is_in_git_repo || return - git -c color.status=always status --short | - fzf-down -m --ansi --nth 2..,.. \ - --preview '(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500' | - cut -c4- | sed 's/.* -> //' -} - -_gb() { - is_in_git_repo || return - git branch -a --color=always | grep -v '/HEAD\s' | sort | - fzf-down --ansi --multi --tac --preview-window right:70% \ - --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES | - sed 's/^..//' | cut -d' ' -f1 | - sed 's#^remotes/##' -} - -_gt() { - is_in_git_repo || return - git tag --sort -version:refname | - fzf-down --multi --preview-window right:70% \ - --preview 'git show --color=always {} | head -'$LINES -} - -_gh() { - is_in_git_repo || return - git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always | - fzf-down --ansi --no-sort --reverse --multi --bind 'ctrl-s:toggle-sort' \ - --header 'Press CTRL-S to toggle sort' \ - --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --color=always | head -'$LINES | - grep -o "[a-f0-9]\{7,\}" -} - -_gr() { - is_in_git_repo || return - git remote -v | awk '{print $1 "\t" $2}' | uniq | - fzf-down --tac \ - --preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" {1} | head -200' | - cut -d$'\t' -f1 -} - diff --git a/fzf-git/key-binding.zsh b/fzf-git/key-binding.zsh deleted file mode 100644 index e44052e..0000000 --- a/fzf-git/key-binding.zsh +++ /dev/null @@ -1,19 +0,0 @@ -join-lines() { - local item - while read item; do - echo -n "${(q)item} " - done -} - -bind-git-helper() { - local c - for c in $@; do - eval "fzf-g$c-widget() { local result=\$(_g$c | join-lines); zle reset-prompt; LBUFFER+=\$result }" - eval "zle -N fzf-g$c-widget" - eval "bindkey '^g^$c' fzf-g$c-widget" - done -} -bindkey -r "^g" -bindkey "^g^g" send-break -bind-git-helper f b t r h -unset -f bind-git-helper diff --git a/nix-conf/home/includes/zsh.nix b/nix-conf/home/includes/zsh.nix index 76107a9..9dd4aa9 100644 --- a/nix-conf/home/includes/zsh.nix +++ b/nix-conf/home/includes/zsh.nix @@ -93,10 +93,6 @@ export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_ALT_C_COMMAND="rg --hidden --files --sort-files --null | xargs -0 dirname | sort -u" - if [ -d ~/fzf-git ]; then - source ~/fzf-git/functions.sh - source ~/fzf-git/key-binding.zsh - fi autopair-init enable-fzf-tab @@ -192,6 +188,16 @@ }; file = "zsh-edit.plugin.zsh"; } + { + name = "fzf-git.sh"; + src = fetchFromGitHub { + owner = "junegunn"; + repo = "fzf-git.sh"; + rev = "9190e1bf7273d85f435fa759a5c3b20e588e9f7e"; + sha256 = "2CGjk1oTXip+eAJMuOk/X3e2KTwfwzcKTcGToA2xPd4="; + }; + file = "fzf-git.sh"; + } ]; }; } diff --git a/setup-home.sh b/setup-home.sh index d951e33..29c621d 100644 --- a/setup-home.sh +++ b/setup-home.sh @@ -12,8 +12,6 @@ HOME_CONF="$HOME/dotfiles/nix-conf/home/${CONF:-${HOST}}.nix" [ -f $HOME_CONF ] && ln -sf $HOME_CONF ~/.config/nixpkgs/home.nix ln -sf ~/dotfiles/.p10k.zsh ~/ ln -sf ~/dotfiles/.emacs.d ~/ -# TODO can this be included in zsh.nix? -ln -s ~/dotfiles/fzf-git ~/ mkdir ~/.config/nix echo "extra-experimental-features = nix-command flakes" > ~/.config/nix/nix.conf |