Skip to content

Instantly share code, notes, and snippets.

@mb720
Created May 21, 2018 15:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mb720/86144b670599c0eab331cd2f48bd23b9 to your computer and use it in GitHub Desktop.
Save mb720/86144b670599c0eab331cd2f48bd23b9 to your computer and use it in GitHub Desktop.
Keybinding to open file selected with fzf in editor
# 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