Created
May 21, 2018 15:00
-
-
Save mb720/86144b670599c0eab331cd2f48bd23b9 to your computer and use it in GitHub Desktop.
Keybinding to open file selected with fzf in editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search a file with fzf and then open it in an editor | |
fzf_then_open_in_editor() { | |
local file=$(fzf) | |
# Open the file if it exists | |
if [ -n "$file" ]; then | |
# Use the default editor if it's defined, otherwise Vim | |
${EDITOR:-vim} "$file" | |
fi | |
} | |
bind -x '"C-o": fzf_then_open_in_editor' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment