Skip to content

Commit

Permalink
Add Alt as modifier key to git log search key binding (#17)
Browse files Browse the repository at this point in the history
After much feedback around git log search's Ctrl+l key binding conflicting with clear screen, I have decided to change its key binding to Ctrl+Alt+l. An alternative option I considered was just Alt+l, which is shorter but I realized conflicts with __fish_list_current_token, which is actually quite useful and I plan on using it now that I've discovered it.

One huge problem with this change is that it is backwards incompatible and fisher has not provided me with a way to announce to users of fzf.fish that the key binding has changed. I had considered using a hack of checking if an arbitrary file existed, printing an error message if it doesn't and then creating that file, but it adds a lot of difficult-to-maintain code and slows down the shell startup.
Hopefully, people who discover that Ctrl+l no longer works will come to this repo and see this commit. I will also create a new release announcing this change. I am sorry for any confusion caused by this.
  • Loading branch information
PatrickF1 authored Aug 15, 2020
1 parent b7b759b commit 29e12f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A plugin that integrates [fzf](https://github.com/junegunn/fzf) into your [fish]
![file search](/images/file_search.png)

> Search for a **commit** in the current git repository's log - `Ctrl+l` (l for log)
> Search for a **commit** in the current git repository's log - `Ctrl+Alt+l` (l for log, Alt to prevent overriding clear screen)
![git log search](/images/git_log_search.png)

Expand Down
8 changes: 5 additions & 3 deletions conf.d/fzf.fish
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Set up the default, mnemonic keybindings unless the user has chosen to customize them
if not set --query fzf_fish_custom_keybindings
# \cf is ctrl+f, etc.
# \cf is Ctrl+f
bind \cf '__fzf_search_current_dir'
bind \cl '__fzf_search_git_log'
bind \cr '__fzf_search_history'
bind \cv '__fzf_search_shell_variables'
# __fzf_search_git_log's keybinding has Alt as an additional modifier key to avoid conflict with
# clear screen (Ctrl+l) and __fish_list_current_token (Alt+l)
bind \e\cl '__fzf_search_git_log'

# set up the same keybindings for insert mode if using fish_vi_key_bindings
if [ $fish_key_bindings = 'fish_vi_key_bindings' ]
bind --mode insert \cf '__fzf_search_current_dir'
bind --mode insert \cl '__fzf_search_git_log'
bind --mode insert \cr '__fzf_search_history'
bind --mode insert \cv '__fzf_search_shell_variables'
bind --mode insert \e\cl '__fzf_search_git_log'
end
end

Expand Down
2 changes: 1 addition & 1 deletion functions/uninstall.fish
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env fish
if not set --query fzf_fish_custom_keybindings
bind --erase --all \cf
bind --erase --all \cl
bind --erase --all \cr
bind --erase --all \cv
bind --erase --all \c\el

set_color --italics cyan
echo "fzf.fish key kindings removed"
Expand Down

0 comments on commit 29e12f8

Please sign in to comment.