Macos – With tmux on OSX, how can I make command+k clear more gracefully

macostmux

When I use the terminal in OSX, I frequently use +K to clear the screen and scrollback buffer. It's deep in muscle memory.

I've started tinkering with tmux, and one gripe is that +K wipes the whole screen, panes and all. What I'd like is for it to affect only the focused pane.

Can I somehow configure this behavior?

Best Answer

Configure iTerm2 to send clear command

Preferences -> Keys -> + (add new global shortcut)

  • Keyboard shortcut: ⌘+k
  • Action: Send text
  • value:

clear\n

Alternatively configure iTerm2 to effectively map ⌘+k to ctrl+l

  • Keyboard shortcut: ⌘+k
  • Action: Send Hex Code
  • value:

0x0c

This way you won't see the text flash and the clear command won't pollute your history.

Related Question