24 May, 2013

tmux clear backscroll...

I've recently started using tmux on my OSX work box. I had avoided it because I've developed a strong attachment to clearing my screen before running commands that are going to kick out a lot of output, which in a regular terminal or iterm2 on a mac is Command+k. Well, if you do that during a tmux session, it clears the tmux screen elements and things are really fubar-ed until you resize the screen. Anyway... I added the following to my .tmux.conf

# clear scrollback
bind-key C-k send-keys -R \; clear-history \; send-keys "Enter"


Which is nice, so I perform a control+b control+k and it clears the screen. However... there's a really nice side effect that I stumbled on completely by accident. If I already have a command queued up and ready to go when I use that keystroke combination, the send-keys "Enter" causes the command to execute.

That way, I get the command to execute and the only output I'll ever be able to scroll to is the entire output of the command! I had added the send-keys "Enter" to this because the rest of the command was leaving me with a blank screen and I had to hit enter to get my prompt back. Now... I have a new workflow I like.

No comments: