Re:Tools I Use - tmux
by sequoia on Sunday January 08, 2012 @12:58AM
(#3439002)
Some other cool features:
Monitoring background windows: with monitor-activity, monitor-silence, and monitor-content [term], you get a visual notification when there is activity, a certain period of silence, or an occurrence of [term], respectively, in a specified background window. Sometimes I open several error logs in a background window and monitor-activity so I get a notification if anything is written.
synchronize-content: I've only used this a few times but it's a neat trick! With several panes open in one window you can send keystrokes to all the panes at once. I've used this while connected to more than one server to compare the contents or make changes simultaneously. I won't claim this is the safest way to work but it comes in handy.
Managing windows and panes in tmux is pretty painless, in my experience. Resizing, switching, etc. are all very simple. One final feature I like, tho it's trivial, is the "show the time" command (bound to prefix-t). Invoking it gives you a nice big digital clock in a window or pane. I put this below my ttytter pane so I don't lose track of time. :)
I don't know how much of this you can do in screen as I've never used it, I'm sure there's a lot of overlap, but as a sometimes very critical software user let me say: I love tmux.
Re:Tools I Use - tmux
by tikhonj on Sunday January 08, 2012 @03:11AM
(#3439147)
I actually use Emacs and shell-mode to do exactly this. It has its own advantages and disadvantages, and only makes sense for people already using Emacs, but it's definitely something to consider.
A neat trick: by default, C-u M-x shell opens a shell with a custom buffer name in another window (in Emacs, the different panes are called "windows") in a specified directory. If you're editing a file remotely with TRAMP, the shell will be opened remotely as well.
I find this really useful when I'm editing multiple files on multiple remote systems and need to run some commands. This also integrates well with the rest of Emacs, making working with multiple shells, different files and other stuff really easy.
Re:Tools I Use - tmux
by jodrellblank on Sunday January 08, 2012 @01:30AM
(#3439028)
I tried tmux earlier today and found a very nice feature:
I have an SSH session to a remote linux server from my computer, then connect a new SSH session from my BlackBerry, and run 'tmux attach' in it.
The tmux session on the computer resizes to the size of the BlackBerry terminal, and both PuTTY and BBSSH show the same content, and both can interact with it.
Disconnect the BB, and the computer terminal resizes back to what it was.
Re:Tools I Use - tmux
by tobych on Sunday January 08, 2012 @01:47AM
(#3439046)
I do the same from my Android phone (using ConnectBot): I can run some long-running process and keep an eye on it while I'm out in the kitchen making a cup of tea. When I'm back in the office, I detach the Android session.
Re:Tools I Use - tmux
by phzbOx on Sunday January 08, 2012 @10:57AM
(#3439761)
I went from "Terminal" to "screen" to "tmux" to "stumpwm". Baiscally, what I really liked of tmux is the way I could frame my terminals logically or fullscreen easily. I also really enjoyed the fact that I had multiple "workspace". Basically, my WM was just not appropriate for the way I liked to work. Stump fixed that. It's dynamic, I can hack it from emacs and it has everything I liked about tmux. Obviously, I'm talking from my desktop perspective, if I'm working somewhere else remotely it's a different story.
Re:Tools I Use - tmux
by tkrajcar on Sunday January 08, 2012 @01:20AM
(#3439018)
I use screen regularly, but mostly to be able to attach and detach to sessions as I move between work, home, etc.
tmux users frequently tout its ability to do nifty split screens and other window management, but I'm not sure I understand the value of doing this over just starting another iterm2 window/tab and using regular window management tools. Cmd-tilde or Cmd-tab is one less key than Ctrl-a, h.... :) What am I missing?
Re:Tools I Use - tmux
by bricestacey on Sunday January 08, 2012 @02:18AM
(#3439092)
If you do dev work on a remote server this is usually not an option unless you're willing to open half a dozen ssh connections, but then none can communicate with each other easily..
I'm sure iterm2 does a fantastic job doing window/tab management, but I spent almost 5 years working over ssh.
edit - tmux is scriptable too, so you can setup a dev environment using a shell script (I do this, setting up my rails server, console, resque workers, etc, etc).
Re:Tools I Use - tmux
by mminer on Sunday January 08, 2012 @02:13AM
(#3439085)
Additionally, iTerm2 supports splitting windows vertically and horizontally, with niceties like dimming inactive panes. However, not all terminal applications support this. When I move from my laptop to a public computer to my iPad I appreciate a consistent experience. If you don't use split windows in the first place then tmux's functionality won't thrill you, but as someone who logs into my dev machine from multiple locations I prefer to rely on the actual terminal application and host operating system as little as possible for window management.
Re:Tools I Use - tmux
by Dejital on Sunday January 08, 2012 @12:10AM
(#3438946)
There are multiple problems with tmux on OS X. pbcopy and pbpaste, for instance, are entirely unusable. Even if tmux has some nice benefits over screen, it probably isn't worth it to the Mac user to switch.
Re:Tools I Use - tmux
by thristian on Sunday January 08, 2012 @12:49AM
(#3438989)
There's a similar-sounding problem in the X11 environment on traditional Unix systems: the current default graphical display is in the $DISPLAY environment variable, while authentication information is in ~/.Xauthority. GNU Screen tends to blindly inherit those settings, so you can freely start GUI apps from inside screen and have everything work... until you try to reattach screen from inside a different GUI session, or from a non-GUI session (say, ssh). Then all the processes you run inside screen go looking for a GUI session that no longer exists and everything starts breaking in odd ways.
tmux actually has a way to work around this: whenever you reattach, it looks at a whitelist of environment variables representing external resources, and either updates its own environment with the new values, or removes those settings from its environment if the place you're attaching from doesn't have them available (naturally this doesn't magically fix any processes already running inside tmux, but every new window you create will be set up correctly - unlike screen, where you have to kill every window and end the session). By defaut, this whitelist includes variables used for X11 authentication and the SSH agent. If OS X has a similar environment-variable-based connection system, you might be able to add it to tmux to get things working.
Re:Tools I Use - tmux
by sciurus on Sunday January 08, 2012 @10:49AM
(#3439747)
GNU Screen allows you to do something similar using its setenv command. For instance, to update the value of $DISPLAY to a new ssh session's value you could run "screen -S foo -X setenv DISPLAY $DISPLAY" before running "screen -r foo".
I have a wrapper script that reproduces tmux's behavior of automatically updating a set of environment variables. It goes a step further and also updates them in your running bash shells. For this to work you have to register a signal handler in your .bashrc that sources a file with the new environment. The script is available at https://github.com/sciurus/splatbang/blob/master/rescreen
The documentation recommends changing tmux's default command, but if that weirds you out, a simple alias to "reattach-to-user-namespace pbcopy" also works.
Re:Tools I Use - tmux
by jamiemill on Sunday January 08, 2012 @05:12AM
(#3439263)
Instead of trying to make the native copy/paste work, can anyone think of a way to set up key bindings in OSX to mimic copy/paste but store the text in /tmp/mypasteboard or something?
Would AppleScript do it and would that work in any application?
Re:Tools I Use - tmux
by technomancy on Sunday January 08, 2012 @11:04AM
(#3439776)
What I don't understand is how both screen and tmux ship with bindings that conflict with readline. Did nobody notice, or did nobody care? Neither is usable without fixing this in config.
Re:Tools I Use - tmux
by yason on Sunday January 08, 2012 @04:44PM
(#3440604)
Configuring the prefix key to C-z is quite harmless, C-z C-z for suspend is quite ok.
(As a bonus hint, binding subkeys with control it's faster to send commands: C-z C-n is faster than C-z n, you just keep control pressed during the command sequence.)
Re:Tools I Use - tmux
by technomancy on Sunday January 08, 2012 @10:17PM
(#3441334)
Of course, it's easy to fix. It just boggles my mind that they would have made that mistake in tmux to begin with when you consider that it's one of the main complaints people have about screen and tmux was supposed to be a "better screen".
Re:Tools I Use - tmux
by lifthrasiir on Sunday January 08, 2012 @03:49PM
(#3440475)
How about C-q as an alternative? It is same as C-v (in the default readline mapping) and generally unused. It does not conflict even with Windows' use of C-v.
Re:Tools I Use - tmux
by te_chris on Sunday January 08, 2012 @01:32AM
(#3439031)
So I've recently got into using vim and quite like the split screen features. How would I mix something like this in for doing day to day running commands and editing stuff with a vim split screen workflow?
Sorry if this seems like a difficult question, but even stories of how people manage this would be great :)
Re:Tools I Use - tmux
by bricestacey on Sunday January 08, 2012 @02:13AM
(#3439084)
I am a tmux/vim user and I find this a constant problem. Split tmux panes don't allow your vim windows to communicate with each other (you could always fallback to using the system buffer, though that is often insufficient). Yet, split vim windows don't allow a shell in a single window.
Re:Tools I Use - tmux
by te_chris on Sunday January 08, 2012 @02:56AM
(#3439133)
Theres actually a vim plugin I've been using that comes with Janus that loads up a shell in a vim buffer. It's been quite helpful, but I still find myself having separate macvim and terminal windows open, especially for rails dev. I normally have vim open for editing and a terminal window open with tabs for rails console, guard for rspec, server and general terminal open.
Re:Tools I Use - tmux
by b14ck on Sunday January 08, 2012 @03:08AM
(#3439144)
I use vim splits as well. I find my typical workflow is something like this:
1) Open a tmux split (vertical).
2) In the left tmux pane, open vim (and split horizontally).
3) On the right side, have my tests open and running via a watch command, eg: watch -n 10 "nosetests", or something similar.
Re:Tools I Use - tmux
by benradler on Sunday January 08, 2012 @02:51AM
(#3439124)
If you like tmux, you may love tmuxinator -- lets you keep your terminal sessions saved (even things like SSH that require login), and resume them exactly as you left.
Re:Tools I Use - tmux
by weehuy on Sunday January 08, 2012 @04:42AM
(#3439250)
This should be added to a FAQ somewhere. Took me ages to figure it out on my own, especially since the error msg is so generic -> http://pig-rabbit.com/tmux-and-launchctl
Re:Tools I Use - tmux
by joeshaw on Sunday January 08, 2012 @09:28PM
(#3441256)
I absolutely love tmux and use it everyday, but the killer feature I really want is tighter integration with a terminal emulator like iterm2. I would love to be able to attach to a tmux session with iterm2 and scroll using two-finger scrolling, while still being able to detach from the session and re-attach remotely.
It would seem like this would be a possibility given tmux's design, which is a lot more flexible than GNU screen's.
Re:Tools I Use - tmux
by pyrhho on Sunday January 08, 2012 @06:28AM
(#3439347)
I keep having this nagging feeling I should use tmux more often. Right now I use it for remote pairing type stuff, but I can never bring myself to use it regularly. I love tmux, and it's super useful, but I just can't deal with the way it breaks scrolling. tmux and screen both horribly break scrolling and reverse searching. I'm not sure what the fix is, but until that works I can't see myself using it regularly.
Re:Tools I Use - tmux
by DrCatbox on Sunday January 08, 2012 @06:43AM
(#3439369)
CTRL+B (or whatever key to get into tmux mode input) then Page Up/Down to scroll or keyup/down. Then just esc when you are done scrolling.
Works fine here, havent needed to mock with settings to make it work like this. But the tildas scrollbar is broken by tmux, and the usual shift+pageup, and mousewheel to scroll... but thats okay.
Re:Tools I Use - tmux
by sequoia on Sunday January 08, 2012 @10:20AM
(#3439680)
When you're in copy-mode (activated by prefix-[ also prefix-pgup as mentioned above) search is like vi or emacs depending on your copy-mode (vi by default I believe).
SO: / to search down, ? to search up. If you want to search from the top down, hit "g" in copy-mode to go to the top of the buffer (in vi mode). "G" to go to the bottom.
These, especially /, are really common conventions. / is used for search by vi, less, Opera (Firefox now too I think), even twitter.com.* My point is that / and ?, and to a lesser extent g/G/etc. soon becomes second nature and are worth learning because they are so common. How do you search backwards from the bottom in iTerm?
Re:Tools I Use - tmux
by justinlilly on Monday January 09, 2012 @01:52AM
(#3441692)
I was rather inspired by this and decided to write up my tmux config with org-babel as literate programming. Hope someone likes it: http://justinlilly.com/dotfiles/tmux.html
Re:Tools I Use - tmux
by dolzenko on Wednesday January 11, 2012 @12:06PM
(#3452569)
One note though - both screen and tmux introduce some delay making the text appear a tad slower (I'm using it over SSH strictly, no idea about 'native console'), does anyone know the solution?
Re:Tools I Use - tmux
by Nick_C on Friday January 13, 2012 @02:13AM
(#3459535)
I think that is more to do with SSH than screen or tmux. I just tested it on a SSH session across the Pacific. No difference whether it is a straight xterm or if it is within a screen session.
Re:Tools I Use - tmux
by dolzenko on Friday January 13, 2012 @08:57AM
(#3460512)
Nick, thanks for reply, I'm definitely seeing the difference, I will do more tests to figure our the bottleneck, have to think a bit about how to measure the delay exactly too (currently I'm using SecureCRT as SSH client, should probably try something else)
Re:Tools I Use - tmux
by akg on Sunday January 08, 2012 @09:47AM
(#3439611)
I love using terminal multiplexors, but prefer GNU Screen since it is almost always available wherever I need it. For those interested, I use the following to show a status line -- comes in handy when you want to name difference screens. You can always name a screen using "C-a A"
Re:Tools I Use - tmux
by keenerd on Sunday January 08, 2012 @12:54PM
(#3440055)
I prefer GNU Screen for the nethack mode. It is a shame that Screen does not ship with a nicer hardstatusline by default - you can do some really amazing things there.
Monitoring background windows: with monitor-activity, monitor-silence, and monitor-content [term], you get a visual notification when there is activity, a certain period of silence, or an occurrence of [term], respectively, in a specified background window. Sometimes I open several error logs in a background window and monitor-activity so I get a notification if anything is written.
synchronize-content: I've only used this a few times but it's a neat trick! With several panes open in one window you can send keystrokes to all the panes at once. I've used this while connected to more than one server to compare the contents or make changes simultaneously. I won't claim this is the safest way to work but it comes in handy.
Managing windows and panes in tmux is pretty painless, in my experience. Resizing, switching, etc. are all very simple. One final feature I like, tho it's trivial, is the "show the time" command (bound to prefix-t). Invoking it gives you a nice big digital clock in a window or pane. I put this below my ttytter pane so I don't lose track of time. :)
I don't know how much of this you can do in screen as I've never used it, I'm sure there's a lot of overlap, but as a sometimes very critical software user let me say: I love tmux.
A neat trick: by default, C-u M-x shell opens a shell with a custom buffer name in another window (in Emacs, the different panes are called "windows") in a specified directory. If you're editing a file remotely with TRAMP, the shell will be opened remotely as well.
I find this really useful when I'm editing multiple files on multiple remote systems and need to run some commands. This also integrates well with the rest of Emacs, making working with multiple shells, different files and other stuff really easy.
I have an SSH session to a remote linux server from my computer, then connect a new SSH session from my BlackBerry, and run 'tmux attach' in it.
The tmux session on the computer resizes to the size of the BlackBerry terminal, and both PuTTY and BBSSH show the same content, and both can interact with it.
Disconnect the BB, and the computer terminal resizes back to what it was.
tmux users frequently tout its ability to do nifty split screens and other window management, but I'm not sure I understand the value of doing this over just starting another iterm2 window/tab and using regular window management tools. Cmd-tilde or Cmd-tab is one less key than Ctrl-a, h.... :) What am I missing?
I'm sure iterm2 does a fantastic job doing window/tab management, but I spent almost 5 years working over ssh.
edit - tmux is scriptable too, so you can setup a dev environment using a shell script (I do this, setting up my rails server, console, resque workers, etc, etc).
tmux actually has a way to work around this: whenever you reattach, it looks at a whitelist of environment variables representing external resources, and either updates its own environment with the new values, or removes those settings from its environment if the place you're attaching from doesn't have them available (naturally this doesn't magically fix any processes already running inside tmux, but every new window you create will be set up correctly - unlike screen, where you have to kill every window and end the session). By defaut, this whitelist includes variables used for X11 authentication and the SSH agent. If OS X has a similar environment-variable-based connection system, you might be able to add it to tmux to get things working.
I have a wrapper script that reproduces tmux's behavior of automatically updating a set of environment variables. It goes a step further and also updates them in your running bash shells. For this to work you have to register a signal handler in your .bashrc that sources a file with the new environment. The script is available at https://github.com/sciurus/splatbang/blob/master/rescreen
https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
The documentation recommends changing tmux's default command, but if that weirds you out, a simple alias to "reattach-to-user-namespace pbcopy" also works.
Would AppleScript do it and would that work in any application?
(As a bonus hint, binding subkeys with control it's faster to send commands: C-z C-n is faster than C-z n, you just keep control pressed during the command sequence.)
Sorry if this seems like a difficult question, but even stories of how people manage this would be great :)
Seems to work quite well, both for simple shell-like programs and full screen-oriented commands.
It does depend on a vim with Python support compiled in, but that doesn't seem like a huge constraint.
1) Open a tmux split (vertical). 2) In the left tmux pane, open vim (and split horizontally). 3) On the right side, have my tests open and running via a watch command, eg: watch -n 10 "nosetests", or something similar.
https://github.com/aziz/tmuxinator
So every terminal window I open already has a tmux inside and I never have that "oh, it would be nice if I haven't forgot to turn tmux on" feeling.
Inside my .vimrc:
This saves the buffer then sends ctr+r to pane 1 (elinks in my case), which causes a page refresh. It's very useful when debugging web scripts.http://blog.dustinkirkland.com/search/label/Byobu
You can use either a screen or tmux backend.
Mac OS X users watch out, launchctl commands barf mysteriously inside of tmux.
Then just alias launchctl to "reattach-to-user-namespace /bin/launchctl"
It would seem like this would be a possibility given tmux's design, which is a lot more flexible than GNU screen's.
Works fine here, havent needed to mock with settings to make it work like this. But the tildas scrollbar is broken by tmux, and the usual shift+pageup, and mousewheel to scroll... but thats okay.
Agree to disagree, I suppose...
How do you do reverse search, though? Any replacement for ITerm's Ctrl-F?
SO: / to search down, ? to search up. If you want to search from the top down, hit "g" in copy-mode to go to the top of the buffer (in vi mode). "G" to go to the bottom.
These, especially /, are really common conventions. / is used for search by vi, less, Opera (Firefox now too I think), even twitter.com.* My point is that / and ?, and to a lesser extent g/G/etc. soon becomes second nature and are worth learning because they are so common. How do you search backwards from the bottom in iTerm?
See "copy-mode" for more info http://www.rootr.net/man/man/tmux/1
*twitter.com (as well as duckduckgo.com and to a limited extend slashdot) uses some sweet vi keybindings. Try n, j, k, r, etc.
All terminals (GNU/Linux) Ive used tmux on, ctrl+r works, and scrolling as described in previous post.
what i dont like about tmux: - it schokes on some weirdo programs while screen seems pretty reliable on anything
thus i end up on screen more often than not