182 points · by jc79 · 12y ago · 117 comments
I had a feature request (256 colors in fbterm so you can get 256 color tmux/vim without x), quickly got patch code, got support (I had never used patch before and didn't tell it to ignore whitespace) and when it worked, was told it would be in 1.9, and there it is. :-)
I'm blaming you =P
In all seriousness actually trying to get 256 colour mode auto detecting and working reliability across different xterms, tmux/screen, ssh and so on, without some hack that forces the 256 on even when it's not supported seems impossible :/
I added the following to my zshrc, which seems to have helped. Why don't these terminals report 256 color mode by default?
if [ "$COLORTERM" == "yes" -a "$TERM" == "xterm" ]; then
export TERM=xterm-256color
fiI suspect terminals don't set 256 colors by default for backward compatibility reasons. tmux itself didn't assume, you needed something in your config file or a command line option. Now though, I believe it can detect it based on your term.
Sidebar: if you're a die-hard tmux user in Linux, and you do something like, say, open vim and then realize you haven't opened it in tmux, check out https://github.com/nelhage/reptyr - it lets you do things like ctrl-z to background vim, start tmux, then steal the vim process into your new tmux session. Pretty cool!
$ stty erase ^?
to recognize DEL (ASCII 127, or ^?) as backspace. I have that in my .bashrc on a particular machine that gives me this problem...
http://askubuntu.com/questions/423529/how-to-efficiently-swi...
What do you mean? Commands like tmux swap-window and tmux move window allow you do move the order of the windows / workspaces.
http://superuser.com/questions/343572/how-do-i-reorder-tmux-...
It kind of works in the end, but it's arguably a bit more awkward to use than in screen.
I know that scrolling is one of the first non-obvious changes that seem irritating at first. But after you get used to scrolling with the keyboard, I find myself missing this possibility on 'standard' terminal windows.
Suddenly using the mouse to scroll feels really awkward and inefficient.
as for selecting copying pasting. i use these options
set -g mouse-resize-pane on
set -g mouse-select-pane on
i can now select and resize panes with the mouse, and i can select while holding the option key on the keyboard.also if you set
setw -g mode-mouse on
you can scroll back with the mouse in the scroll back buffer without having to press c-b[ and it will still properly scroll everywhere else... vim/weechat/etc.on a mac, iterm2 does this natively(in linux it works anyway). but if you want to use that in terminal or totalterminal(quake term) you'll need to install mouseterm. I recommend using mouseterm-plus as i recall mouse term is no longer maintained.
edit: looks like the link is dead you'll have to build it yourself https://github.com/saitoha/mouseterm-plus
Sometimes your hand is on the mouse and it makes for sense to use it.
I don't mind people who don't want to use the mouse, that's fine, but personally I sometimes don't run tmux when I know it will upset my scrolling and cut+pasting.
edit: corrected hotkeys
1) You have to have a separate terminal window for the 'control' process.
2) Now creating new tabs / windows automatically creates them in said tmux session (unless you manually use the "Profiles" drop-down menu). It would be nice to use Tmux as a way to create a window full of tabs in a scripted way (a la Tmuxinator), but not be forced to use a single Tmux session for everything.
I use iTerm. I use ssh to regularly access about 20 other boxes. I create tabs for every task. So I might have 3 tabs for a single box. 1 to start/stop processes, 1 to edit files, 1 to tail logs to verify my crap's working.
I installed tmux and I couldn't figure out what I'd use it for. This might be completely wrong, but I thought it'd allow me to control multiple boxes from a single session.
For example, I have 5 production servers that set up the same way. I want to do the same thing on all 5 at the same time. So my input/output is multiplexed to 5 boxes in a 1:5 relationship. Only I couldn't get that to work. I got lost switching sessions/contexts.
Again, sorry for being thick. I feel like I'm missing something great here.
With tmux, no HUP happens on the server side so the process keeps running. Once your internet connection comes back online you ssh back into the machine and ``tmux attach`` to the previous session. And voilà, it is like nothing happened. All of your output from before is still there too.
This should synchronize the input to all panes i.e. type in any one and it will be sent to all 5. to turn it off, just run the same command again. I don't know if tmux has equivalent synchronize-windows.
It is always persistent so you have your tabs all set up on each server. You just attach to the sessions of TMux on the servers and don't have to ever create your complex scheme on your local machine. You can have them start on boot on the server and just attach to them via ssh.
My case I use WeeChat (IRC) on my home server always running and I just ssh to my server and attach to that session.
Here's how it looks http://i.imgur.com/dEpQYJf.jpg
I started using tmux just because I was frustrated that I would occasionally kill the terminal with Command + Q instead of just the current window Command + W. But now there is just so much of tmux that helps my daily work flow I don't know how I ever got by without it.
This kind of annoys me, but I'm successfully using this workaround (hinted at in the announcement):
bind c run 'tmux new-window -c "#{pane_current_path}"' bind-key '%' split-window -hc "#{pane_current_path}" bind-key '"' split-window -vc "#{pane_current_path}"
Anyone know why this change was made?
if-shell "[[ `tmux -V` == *1.9* ]]" \
'unbind c; bind c new-window -c "#{pane_current_path}"'Currently a byobu user, it seems fine so far. Wondering what others offer more than that.
I'll use screen when I need to run a long-running task and can't keep my terminal session open.
I use tmux with a script so that I can ssh into multiple nodes and broadcast the same commands to them all at the same time. Great for interactive deployments that I haven't been able to automate away with CFEngine just yet.
I sometimes need to do this with multiple VMs. I'm really, really not in favor of bash scripting, but I've found the following to suffice, without the tmux dependency:
for host in box1 box2 box3; do ssh $host 'command; command; command'; done
(This presumes you've set up ssh-agent or are using passphraseless keys and suitable stanzas in ~/.ssh/config; adjust to taste if not.)I'd never heard of using tmux in this fashion before. Is it that the task sufficiently resembles a nail, or does tmux provide some unique benefit here?
My shell script takes in a list of tuples (hostname plus a special id that I need to paste for my tasks that's unique to each host), splits off a window pane for each hostname(tmux split-window -h), ssh's into each host in it's own pane, and turns on synchronization.
I did a little trick to setup pastebuffers to hold that special id from the tuple i passed in. And setup keybindings so that I can press a key combination to paste in that ID whenever I need it to each respective pane.
If I ever need to temporarily remove a pane or several panes from the syncronized session but keep the others synced, I just change focus to the pane I want to unsync and put it into copy mode with "Ctrl-b [". Can take the pane back out of copy mode by hitting "q".
So far it's made me much more productive when I have to run a bunch of identical commands on a cluster of nodes for which we have no defined process (i.e. I'm figuring it out as I go).
I'll need to sanitize the script, but I'll try to put up a github gist of the script later on.
https://twitter.com/j_melis/status/179173797285478400
Seems like a neat trick
$ ssh hostname
$ screen
# some time later, you get disconnected...
$ ssh hostname
$ screen -x
# back to where you were before getting disconnected.I'm using screen right now to scp 4.5Gb from home to my Docker host. I'll close the terminal at some point and check progress tomorrow.
I guess you could do that in Docker.. but why would you?
I use it all the time on my RasPi at work, running a mutt instance. I can hop in from any machine and have my 'native' email client accessible.
It's just an example. Tux lets you automate interactive shells.
https://github.com/andyhmltn/dotfiles
That contains two tmux config files that add a few things like CTRL+B thenSHIFT+P for a nice layout and a shortcut for switching between panes with ALT+Arrow keys
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
(...) For an IMHO even more convinient ALT+Number to switch directly to the tab in question, just like in firefox.
bind-key -n C-up next
bind-key -n C-down prev
ctrl-left and alt-left/right interfere with too many other cli apps.https://github.com/fishman/dot_files/blob/master/tmux/.tmux....
Cmd-shift-c: New window
Cmd-shift-l: New pane to the right
Cmd-shift-h: New pane to the left
Cmd-shift-k: New pane above
Cmd-shift-j: New pane below
Cmd-l: Focus pane on right
Cmd-h: Focus pane on left
Cmd-k: Focus pane above
Cmd-j: Focus pane below
Cmd-1: Select first window
Cmd-2: Select second window
...
Option-h: Previous window
Option-l: Next window
Command-/: Enter copy mode
I have the same bindings in MacVim. The nice thing about using command is that it doesn't interfere with other cli apps like ctrl.The following allows you to yank the tmux clipboard into the system clipboard: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
You can remap left command to left option, leaving right command as command so you can still cmd+tab out of iTerm. You might also have to to to Preferences -> Profiles -> Keys and on the bottom say that the left and right option keys both act as +Esc.
If there's a better way I'd be interested to hear it, but this works for me.
$ tmux detach
$ tmux attach
This will deattach and reattach a tmux session. You can type ``tmux detach`` inside a tmux pane of the session you want to detach. Also the key combo ``Ctrl-b d`` will detach.If you mean a way to save the workspace configuration, tmuxp, teamocil and tmuxinator are great solutions.
(Note, I wrote tmuxp as a python project a few months ago.)
For this reason, I typically simply 'tmux detach;tmux attach"
tmux new -s session_name
Then to reattach tmux attach -t session_name
Read it as "tmux, attach to session_name"Forget which sessions you have open? List them out!
tmux ls