r6saiq
Last Updated: May 05, 2017
·
1.434K
· codezombie
B9d5abee1482afbf6b987edd5e95e7b5

iTerm2 + Tmux + Cmd-K

Cmd-K is known to clear the static stdout in terminal.app and iTerm which doesn't work well at all with tmux. However, with the below key binding in iTerm2 you can clear the scroll back buffer per-pane.

In tmux.conf set the following binding

bind C-k send-keys -R \; clear-history

In iTerm2 preferences, in the Keys tab add a keybinding like the following.

Picture

Caveats: This will override Cmd-K in iTerm2 for all non-tmux windows as well. However, if you work in tmux often, it might just be worth it.

Say Thanks
Respond

1 Response
Add your response

28895
50cccf39f34ae543344049a90deb9cfd

I use this to prevent things from getting wonky when I reflexively hit cmd-k when in a program that doesn't share the its buffer with tmux:

bind k if-shell -F "#{alternate_on}" "#" "send-keys -R; clear-history; send-keys C-l"

It wraps the screen-clearing command with a check to see if you're currently in alternate screen mode, and does nothing if you are.

8 months ago ·