naia<p>Today I learned: you can use `bind -x` to make bash execute code whenever you type some key chord.</p><p>Example: get CTRL-o to fuzzy-find a file. (using <a href="https://lor.sh/tags/fzf" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>fzf</span></a> ❤️ )</p><p>```bash<br>bind -x '"\C-o": xdg-open $(fzf --height 50% --reverse)"<br>```</p><p>My *very* current setup is bit more than this, since I might want to jump<br>to a folder, and since my muscle memory is used to `C-x C-f` to <br>find-file under <a href="https://lor.sh/tags/emacs" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>emacs</span></a> </p><p>```bash<br>bind -x '"\C-x\C-f": find_file "$(fzf --preview "bat --style=numbers --color=always --line-range :500 {}" --walker=file,dir,follow,hidden --height 50% --reverse)"'</p><p>find_file() {<br> echo<br> if [ -f $1 ];<br> then<br> echo "Opening "$(tput bold)$(tput setaf 2)$1$(tput sgr0) && history -s xdg-open $1 && xdg-open "$1" && xdg-open "$1";<br> elif [ -d $1 ];<br> then<br> cd "$1" && echo "Now at "$(tput bold)$(tput setaf 2)`pwd`$(tput sgr0);<br> fi<br>}<br>```</p><p><a href="https://lor.sh/tags/til" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>til</span></a> <a href="https://lor.sh/tags/bash" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>bash</span></a> <a href="https://lor.sh/tags/fzf" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>fzf</span></a></p>