-
Notifications
You must be signed in to change notification settings - Fork 150
Description
Check list
- I have read through the README
- I have the latest version of forgit
- I have searched through the existing issues
Environment info
- OS
- Linux
- Mac OS X
- Windows
- Others:
- Shell
- bash
- zsh
- fish
Problem / Steps to reproduce
This came up during a discussion in #251.
fzf
supports a list of possible hotkeys that can be bound to custom commands and then be called on list items while browsing them. I personally make use of this in my gss
selector by defining these options:
# Use forgit diff on stash enter
export FORGIT_STASH_ENTER_COMMAND='echo {} | cut -d: -f1 | xargs -I % git forgit diff %^1 %'
# Pop stash on alt-enter
export FORGIT_STASH_POP_COMMAND='echo {} | cut -d: -f1 | xargs -I % git stash pop %'
# Drop stash on alt-backspace
export FORGIT_STASH_DROP_COMMAND='echo {} | cut -d: -f1 | xargs -I % git stash drop %'
export FORGIT_STASH_FZF_OPTS="
--preview-window=top:50%
--bind='enter:execute($FORGIT_STASH_ENTER_COMMAND)'
--bind='alt-enter:execute($FORGIT_STASH_POP_COMMAND)+accept'
--bind='alt-bspace:execute($FORGIT_STASH_DROP_COMMAND)+reload(git stash list)'
--prompt='[ENTER] show [ALT+ENTER] pop [ALT+BACKSPACE] drop > '
"
This makes the stash selector look as follows:
I can now view, apply or drop stashes all from within the same stash list.
I kind of "hijacked" the fzf prompt to display the available keybindings. Something similar could be achieved passing --header "[ENTER] show [ALT+ENTER] pop [ALT+BACKSPACE] drop" --header-first
to fzf
, which might be a bit cleaner. I just found putting it into the prompt visually more appealing.
@cjappl @sandr01d @wfxr
How do you like this? Can you imagine including this kind of functionality into forgit? We could make use of this in other forgit dialogs as well, e.g. keybindings in glo
for reverting the selected commit or starting a rebase on it.
Let me know what you think.