With tmux on OSX, how can I make command+k clear more gracefully?
Solution 1:
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.
Solution 2:
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.
Solution 3:
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.
Solution 4:
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.