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?


Configure iTerm2 to send clear command

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

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


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

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


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

  • 2
    Simple and elegant solution. Thank you, my friend.
    – Rafael
    Mar 18 '16 at 3:37
  • Beautiful solution! You've made my tmux experience far more enjoyable. Thank you :)
    – Matt Darby
    Jun 2 '16 at 2:54
  • Just a warning, this will flash the text to the terminal
    – Jay
    Jun 21 '16 at 20:13
  • 2
    This is great, but it relies on the clearcommand and therefore won't work while inside irb or rails console.
    – Robert
    Jan 20 '17 at 21:22

You can use prefix+r, after the +K, to redraw the tmux window.

If you can break the habit, a normal ctrl+l works normally per pane.

  • 3
    ctrl+l is not the same as cmd+k because you can still scroll up and see old history with ctrl+l. If you're tailing a log for example that quickly fills your scroll back cmd+k is invaluable because you know exactly when you last left off. ctrl+l will not do this for you.
    – Bjorn
    Jun 3 '14 at 15:44
  • @BjornTipling ⌘+K is a feature of the terminal emulator, and will not work inside tmux... this binding is designed to wipe the static stdout, which is not how tmux ,and other programs like vim/emacs/weechat/mutt, are being displayed.
    – demure
    Jul 4 '14 at 23:18
  • 1
    +1 for breaking the habit, I can't stop doing it until today. The best thing is to type clear instead I guess
    – zanona
    Nov 21 '14 at 16:11
  • how did you find out to do ctrl+l
    – Honey
    Feb 2 at 13:04
  • @Honey ctrl+l has been the traditional clear binding in *nix for decades. If you want to be aware of things like this, you can read the documentation for the tools you use: ie man bash
    – demure
    Feb 3 at 14:35

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

Got this from here

Props to him. This works for me just like Cmd+k works on the terminal emulator, and works for me on macOS 10.12.5 with iTerm2.

  • Works like a charm, even when a command like tail -f ... or a server is running!
    – Derek
    Nov 14 '18 at 9:00
  • Unfortunately, it's in conflict with nano cut text command ^K. Jul 31 '20 at 13:58

You can add the following lines in your .tmux.conf:

# clear the current pane
bind -n C-k send-keys C-l \; clear-history

Then reload your tmux config. Now you can use your bind key +k (e.g.: Ctrl+b,k) to clear the current pane.

I don't know the syntax for OSX but I guess you can easily adapt the line.

  • I see that C-l clears the screen and clear-history clears the scrollback buffer. What does the \; part do? Feb 18 '16 at 11:58
  • it runs both @NathanLong
    – Jay
    Jun 21 '16 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.