fzf has some keybindings of which some are listed below as examples:
- Alt+C:
cd
into the selected directory - Ctrl+T: select a file
I want to add a keybiding so that I can launch the selected file with fzf
, maybe using xdg-open
or mimeopen
.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityfzf has some keybindings of which some are listed below as examples:
cd
into the selected directoryI want to add a keybiding so that I can launch the selected file with fzf
, maybe using xdg-open
or mimeopen
.
Add this to your .bashrc
:
bind -x '"\C-o": file="$(fzf --height 40% --reverse)" && [ -f "$file" ] && xdg-open "$file"'
Restart your terminal, or run source .bashrc
.
Now you can use Ctrl+o to open files directly with preferred application.
history -s xdg-open "$file"
before the actual command is run so that it's also added to history. Otherwise one misses out on history features, like using the up arrow to quickly re-run the last command---which is more efficient than using ctrl-o again.
Sep 8 at 9:33