DEV Community

Josh Medeski
Josh Medeski

Posted on

Popup history with tmux and fzf

fzf-tmux history popup

Many times a minute I use the keyboard shortcut in my terminal to pull up my history. The 80/20 rule states that 80% of the input comes from 20% of the output. Applying that principle to my activity in the terminal means the majority of commands I want to run I

Thankfully fzf wrote a fzf-tmux script that makes it easy to integrate fzf with tmux.

Make sure you have installed the keybindings for your shell (you'll run something like /usr/local/opt/fzf/install in macOS). After running that command your <ctrl-r> command will be bound to your history.

Going one step further, tmux has floating window support. To set your history to popup, add the following variables to your shell.

Here's my configuration with fish:

export FZF_TMUX_OPTS="-p"
export FZF_CTRL_R_OPTS="--reverse --preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
Enter fullscreen mode Exit fullscreen mode

The -p flag will now change all fzf_tmux behavior to pop up instead of creating a separate pane.

I chose to use --reverse on the <ctrl-r> options because I like the way it looks. I also added an optional preview flag bound to ? as described in the fzf key binding wiki.

I hope you like it! fzf-tmux with popup support has been a game-changer. I had some hesitations moving away from Visual Studio Code, mostly that tmux and neovim felt outdated when it came to visuals. But now, I'm liking this setup MORE than vscode and am excited to continue to tweak the system to be even more stylish and functional than any other IDE out there.

This is a simple change, but having a polish balanced screen makes all the difference for me, here it is one more time:

fzf-tmux history popup

Thanks for reading, I will continue to post tips and tricks for how to be more productive in the terminal and macOS, hit that follow button if you want to get more articles like this and hit one of those emojis in the sidebar if you liked this tip.

Top comments (0)