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.

| improve this answer | |
  • 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
  • 1
    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.

| improve this answer | |
  • 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

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.

| improve this answer | |
  • 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. – Krzysztof Przygoda Jul 31 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.

| improve this answer | |
  • I see that C-l clears the screen and clear-history clears the scrollback buffer. What does the \; part do? – Nathan Long 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.