DEV Community

Play Button Pause Button
Waylon Walker
Waylon Walker

Posted on • Updated on • Originally published at

🚀 boost your tmux productivity with 🎯 targeted

Hold on to your hats folks, we are going to start adding some rocket fuel to your tmux. We are going to configure tmux to open applications you need on a regular basis in an instant.

Scripting tmux to open up specific applications can be intimidating your first time. It can be tricky to get it to start in the right directory. If you are trying to assign applications to a keybinding it can be easy to mess up and have weird things happen every time your ~/.tmux.conf gets sourced.

Open htop in an above split

I used this one for a number of years to take a quick peek into my systems performance while a memory intensive task was running.

bind -n M-t split-window htop \; swap-pane -U
Enter fullscreen mode Exit fullscreen mode

🗒️ note that the swap-pane -U will make the htop split active immediately

Open htop in a popup

With the new tmux popup windows I really like the flow of just peeking at htop in a popup and jumping back into what I was doing. It can have a more consistent look, and not mess with the window layouts.

bind -n M-t popup -E -h 95% -w 95% -x 100% "htop"
Enter fullscreen mode Exit fullscreen mode

Open an application in the current directory

One thing that can be tricky is getting apps that need to be in a specific directory started in the directory that you want. Here are two examples I use to open vifm or gitui.

bind -n M-e split-window -c '#{pane_current_path}' vifm . .\; resize-pane -Z;
bind C-k split-window -c '#{pane_current_path}' 'gitui'\; resize-pane -Z;
Enter fullscreen mode Exit fullscreen mode

🗒️ note that split-window takes in a -c flag before the application you
want to run to specify the startup directory.

Open a popup in a specific directory

I've been converted over to using popups for these as well. I'll admit that the workflow of creating a new full screen window may have been better, but this can be a bit less jarring, espessially if you have anyone following along with what you are doing.

bind -n M-e display-popup -d '#{pane_current_path}' -E vifm
bind C-k display-popup -d '#{pane_current_path}' -E 'gitui'
Enter fullscreen mode Exit fullscreen mode

Be sure to check out the full YouTube playlist and subscribe if you like it.

tmux playlist on youtub

Also check out this long form post for more about how I use tmux.

Top comments (0)