{"id":344,"date":"2012-06-19T07:09:35","date_gmt":"2012-06-19T04:09:35","guid":{"rendered":"http:\/\/www.held.org.il\/blog\/?p=344"},"modified":"2012-06-21T00:00:10","modified_gmt":"2012-06-20T21:00:10","slug":"improve-your-shell-experience-with-tmux-conqueterm","status":"publish","type":"post","link":"http:\/\/www.held.org.il\/blog\/2012\/06\/improve-your-shell-experience-with-tmux-conqueterm\/","title":{"rendered":"Improve your shell experience with tmux &#038; ConqueTerm"},"content":{"rendered":"<p>As a power text-mode user, I was both surprised and glad to hear (10x <a href=\"http:\/\/www.twitter.com\/erikzaadi\">@erikzaadi<\/a>!) about two interesting tools: <a href=\"http:\/\/tmux.sourceforge.net\/\">tmux<\/a> &amp; <a href=\"http:\/\/code.google.com\/p\/conque\/\">ConqueTerm<\/a>, which significantly changed the way I use the shell\/terminal. I'll try to keep it short and to the point, and briefly explain the most notable behavior-changing features the way I see them. Or in other words: why should you give them a try.<\/p>\n<h3>tmux<\/h3>\n<p><a href=\"http:\/\/tmux.sourceforge.net\/\">tmux<\/a> is <em>screen<\/em>-like. I didn't get to learn much of <em>screen<\/em> (absolutely my bad), so it's really not a \"why tmux is better than screen\" post, but simply what goodies does tmux provide.<\/p>\n<h4>tmux goodies:<!--more--><\/h4>\n<ul>\n<li><strong>Detach and reattach to the whole session.<\/strong> Even when X\/ssh dies: this is basic, and that's what <em>screen<\/em> is most widely known for, but it's so important.<br \/>\n<strong>&gt; list all sessions: tmux ls<br \/>\n&gt; attach a certain session: tmux attach [-t &lt;num&gt;]<\/strong><br \/>\n<strong><\/strong><\/li>\n<li><strong>Keep<\/strong> <strong>multiple copy-paste buffers<\/strong>. It'll stay there for as long as the session is alive. It'll not live through reboots, but will live multiple days through ssh logins, X crashes. When using multiple tmux sessions (e.g. I have one on each screen), all share the same copy-paste buffer. Bonus: no mouse involved \ud83d\ude42<br \/>\n<strong>&gt; Copy: <\/strong>Ctrl+B+[ . I find it much easier keyboard-wise with\u00c2\u00a0 'set -g mode-keys vi' in ~\/.tmux.conf. So that I move with vim keys (0, $, b, B, w, W), Space starts selection, Enter finishes.<br \/>\n<strong>&gt; Paste:<\/strong> Ctrl+B+]<br \/>\n<strong>&gt; View clipboard buffers and choose what to paste: <\/strong>Ctrl+B+=\u00c2\u00a0 (so cool!)<\/li>\n<li><strong>Keyboard controlled tabs<\/strong> (\"windows\") and window splits (\"panes\"). It's hard to explain its strength, but think of running some long running command - you want to see the output but in the meantime to run something else. Ctrl+B+^ will split the screen and provide bring a new shell above it. Much nicer than shell job control.<br \/>\n&gt; <strong>Create panes:<\/strong> Ctrl+B+\", Ctrl+B+% . <strong>Navigate:<\/strong> Ctrl+B+Arrow keys<br \/>\n<strong>&gt; Create window:<\/strong> Ctrl+B+c . <strong>Navigate:<\/strong>Ctrl+B+(p\/n\/#)<\/p>\n<ul>\n<li><strong>Run command in a split: <\/strong>this one is very handy. Split dies when command dies.<br \/>\n<strong>&gt; tmux split [-h] top<\/strong><br \/>\n<strong>&gt; tmux new-window tar -xvf \/tmp\/my.tar.gz<\/strong><\/li>\n<\/ul>\n<\/li>\n<li><strong>Scrollable, searchable, copyable, super-long buffer:<\/strong> basic, but well-made.<\/li>\n<li><strong>Remote pair programming: <\/strong>it's a killer one. I know, <em>screen<\/em> has it too, but it's worth mentioning. The other peer, being logged in to the same host as the same user as you, simply needs to use 'tmux attach' to attach to the specific session.<\/li>\n<li><strong><a href=\"https:\/\/github.com\/aziz\/tmuxinator\">tmuxinator<\/a><\/strong>: I didn't yet make good use of it, but it certainly redefines the meaning of \"cool\".<\/li>\n<\/ul>\n<p>You can check out my <a href=\"https:\/\/github.com\/orenhe\/dotfiles\/blob\/master\/.tmux.conf\">tmux.conf<\/a>, and this <a href=\"https:\/\/github.com\/scharan\/Goodies\/blob\/master\/ssh-agent-restore\">ssh-agent-restore helper<\/a>.<\/p>\n<h3>ConqueTerm - a console buffer inside vim<\/h3>\n<p>I never got to play well with Emacs. But I must admit it's strong. One of the features I got excited about was that anything is a buffer, either a text file or a console. And since seeing it, I was looking for a vim equivalent. And just when I gave up, ConqueTerm appeared.<\/p>\n<h4>ConqueTerm goodies:<\/h4>\n<ul>\n<li><strong>Output is a vim buffer<\/strong>: it's fun using the familiar vim tools on your output: search, navigate, select and copy, % for brace matching, etc.<\/li>\n<li><strong>Copy-and-paste<\/strong> between a regular edited file and the terminal buffer in both directions.<\/li>\n<li><strong>Brace matching<\/strong> on command line: running a complex command line with all sorts of braces? a well-configured VIM would highlight the matching brace when cursor is over it.<\/li>\n<li><strong>Keyboard-controlled<\/strong> <strong>window sizing and position<\/strong>: create the terminal buffer as a vertical split, resize, etc.<br \/>\n<strong>&gt; Also possible to modify after creation: <\/strong>I found Ctrl+W+J (capital J) pretty useful, as well as the other H,K,L vim navigation keyskeys). It changes the window layout by saying \"current window stays on bottom and uses all of it.<strong><\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a power text-mode user, I was both surprised and glad to hear (10x @erikzaadi!) about two interesting tools: tmux &amp; ConqueTerm, which significantly changed the way I use the shell\/terminal. I&#8217;ll try to keep it short and to the point, and briefly explain the most notable behavior-changing features the way I see them. Or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[188,189,198,103,190,187],"_links":{"self":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/344"}],"collection":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/comments?post=344"}],"version-history":[{"count":0,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/344\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/media?parent=344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/categories?post=344"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/tags?post=344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}