11 ms·
An introduction to Tmux
- ndmrs 11y agoI love tmux but it appears to be messing with my terminal colors for some reason, especially in vim and after enabling 256 color mode.(Also the line numbers in vim appears to be bold in tmux when they aren't if run directly from the terminal, weird.)
- tyingq 11y agoA couple of potential fixes: # Force tmux to assume the terminal supports 256 colors tmux -2 # if /usr/share/terminfo/x/xterm-256color exists export TERM='xterm-256color' # otherwise export TERM='xterm-color'
- towb 11y agoTmux recently merged a PR adding 24-bit colour, I'm a lot happier with the colours now. I think it will be in the next release if it's not out already. https://github.com/tmux/tmux/pull/112 https://github.com/tmux/tmux/pull/112
- thristian 11y agoYou may have hit the difference between what a terminal is capable of, versus what it's actually capable of. Most modern terminals can do all kinds of fancy things like mouse-support and 256-colour output, but they advertise themselves as 1990s-era 8-colour devices for compatibility reasons. Specifically, they set $TERM to "xterm" or similar. tmux is two kinds of terminal application: it interacts with your outer, "real" terminal, and it presents an inner, "fake" terminal to the programs running inside it. By default, tmux will respect the limitations implied by $TERM, so if your outer terminal claims to be an 8-colour device, tmux will filter the colours of applications inside it to fit the standard 8-colour palette. Vim also respects the limitations implied by $TERM, but some people override it into using 256-colour mode anyway, by doing something like "set t_Co=256" in their .vimrc. That works for Vim running in the outer terminal, but it doesn't work for any other tools running in the outer terminal, and in particular it doesn't help tmux. These days, it's generally best to configure your terminal app to set $TERM to something like "xterm-256color", "nsterm-256color" (for Terminal.app), "putty-256color" (for PuTTY), "gnome-256color" (for libvte-based emulators) or similar. If your terminal application doesn't support manually overriding $TERM, you can do it in your shell profile. That way, every app should understand your terminal's capabilities, including 256-colour support, both inside and outside of tmux.
- azaras 11y agoI recommend Byobu. Byobu is an elegant enhancement of tmux or Gnu Screen. For me Byobu is for far easier to use than Tmux.
- wodenokoto 11y agoThat's a really nice introductory video they have on the website. The classical music is also a nice touch. http://byobu.co http://byobu.co
- spinningarrow 11y agoCan you elaborate why? I saw most of the video on their website; it looked pretty similar to tmux (with different shortcut keys). Does it have any extra features? Perhaps out-of-the-box session saving even after rebooting?
- superobserver 11y agoA couple of obvious reasons: 1) it lowers the bar of entry into Tmux/Screen for newbies; 2) it has fairly intuitive mappings for newbies; 3) it is sanely configurable whilst not requiring the direct use of a dot file (just hit F9); 4) it may be faster to set up than Tmux/Screen (assuming you aren't able to copy a conf file for those); 5) it doesn't require understanding Ctrl-b/a for prefixing most commands.
- ghshephard 11y agoI watched the video for a while - and it looks almost identical to tmux - basically tmux with different key-mappings. I'd almost guess that the someone has simply gone and skinned the base tmux, everything looks so similar - panes, sessions, windows, resizing, scrollback, etc... If you already are familiar with tmux, I don't think Byobu will get you anything (based on what I saw of the video).
- drummer32 11y agoYeah, byobu is pretty much an opinionated tmux/screen (you can choose a backend).
- renke1 11y agoI can only recommend tools like tmuxinator [1]. They make it really easy to start your development environment. Especially when you deal with multiple services that need to be started along with certain tasks (mostly watch tasks like build and test in my case). [1]: https://github.com/tmuxinator/tmuxinator https://github.com/tmuxinator/tmuxinator
- anilgulecha 11y agoAlso https://github.com/oxidane/tmuxomatic https://github.com/oxidane/tmuxomatic, whose ASCII layout format I find stupid easy to create custom windows and screens.
- renke1 11y agoWow, that's pretty cool. I tend to use windows a lot though. Within a window I usually have 3-4 panes that I manage using Ctrl-B space to switch layouts.
- KKKKkkkk1 11y agoIs tmux a MacOS thing? I don't understand why would I want to use it on my machine. I already have a terminal multiplexer - it's called gnome-terminal and it supports tabs and multiple windows. Why would I want to add a clunky middle man with weird key combinations that messes with scrollback and colors?
- lunchladydoris 11y agoFor many people it will be the persistence of sessions on remote machines. I never use it remotely though and still love it, mainly because it's so easy to switch between windows and panes without having to use a mouse.
- KKKKkkkk1 11y agoI used to love screen when I worked on a remote machine (no tmux on that machine, unfortunately). But it seems people are using it locally. Is it purely a matter of habit? In gnome-terminal, I'm switching between tabs with Ctrl-PgUp and Ctrl-PgDown and between windows with Alt-Tab. What can be easier than that?
- xrstf 11y agotmux can easily split windows vertically/horizontally. I'm not using gnome-terminal, so I don't know if it or your desktop environment makes splitting so quick. I could also imagine using one window manager on remote systems and locally is just easier to remember.
- ghshephard 11y agoOpening up panes on Tmux is pretty nice - Prefix-" or Prefix-% to get Horizontal or Vertical Panes. Copy/Paste Buffers are useful once you get the hang of them. Also - once you master it - it doesn't really matter what system you are coming from - the interaction is the same. Windows, OS X, Linux, Heck - OpenBSD console - the interaction is the same. I wouldn't be surprised if my Circa 1980 IBM 3101 Terminal is mostly supported by Tmux. (maybe a missing Meta Key, but that isn't used that much by Tmux)
- lunchladydoris 11y agoOne of the best tips I got when setting up tmux was to change the default prefix to ctrl+a. That combined with remapping caps-lock to ctrl makes working with tmux much more comfortable.
- ghshephard 11y agoOr ctrl+s - (I use Ctrl-a all the time to go to beginning of line). Particularly if you remap Caps-Lock to Ctrl, it's pretty comfortable combination.
- kr0 11y agoThe images depict manuals for screen.
- ashwinaj 11y agoI would recommend using mosh+tmux, rather than ssh+tmux, especially if you're using a laptop to connect to your remote development machine.
- goerz 11y agoIdeally yes, but unfortunately mosh doesn't get through most firewalls, as far as I can tell. A lot of networks filter everything except port 22.
- piratebroadcast 11y agoSerious Question: Why would I want to use Tmux instead of iTerm with multiple tabs open? I don't think I get it. Can anyone ELI5?
- blakesterz 11y agoSpeaking as someone who doesn't use it, but understands it well, the one and only thing that excites me is the persistence of sessions, if your connection drops, you can reconnect and everything is still there. Love that idea. Everything else is solved that I know it does well (for me) by using tabs. I could very well be missing other things, I know it does quite a bit, but most of the things I see other people use it for is solved by tabs (for me at least).
- tburmeister 11y agoThis is the big thing for me. I used to work almost exclusively on a remote dev machine, using my laptop as a terminal, and tmux meant I could pick up in the morning where I left off the day before. Now, I work on a desktop, but I've gotten used to using tmux and using it locally means I can ssh to my work machine from home and, again, pick up where I left off.
- tyingq 11y agoSession sharing is also handy in specific cases. It supports both read only, and read/write shared sessions. The other feature that's used often is the general scriptability that the command line options make possible. "send-keys" for example can be useful...it sends keystrokes to specific named sessions.
- StavrosK 11y agoDoesn't mosh do that as well (or better)?
- Freaky 11y agomosh only supports reattaching from the originally started client - no attaching from different machines, no resuming sessions after reboots, etc. Also no splits, and no scrollback. It's also extremely slow. Fullscreen terminals on my 30" display are borderline unusable with mosh.
- auxym 11y agoI use it over ssh. 1 ssh session, multiple terms/windows/etc. And persistence of sessions.
- n0us 11y agoWorth noting that you can enable mouse mode which is significantly easier for scrolling. It's also recommended by most people that you remap Caps-Lock to Ctrl and change the activation key from b to a. There are some great themes that make it nicer to look at as well. I use tmux all the time for things like sshing into a vagrant box. As soon as I'm in I can switch between the tail of my logs, the readout of my build tool, the dev server readout etc. No more fumbling around starting multiple ssh sessions in multiple iTerm tabs. tmux honestly has been a game changer in terms of productivity just because of how easy it is to open things up and look at them. For those who are wondering why you wouldn't just use tabs in iTerm, its really more of an "also" not an "or"
- branchless 11y agoI use emacs and most keys are bound. I'm really wondering what emacs devotees use with tmux.
- sbagley 11y agoTry this: unbind C-b set -g prefix ` bind ` send-prefix
- robenkleene 11y agoI use Emacs on and off, as well as Vim, and the key I've settled on for tmux prefix is ^q. It doesn't conflict with anything useful (that I've found anyway) and it's easy to hit with a caps lock as control. For the record ^b is also move backwards by character in basic readline bindings (so it works in Emacs, on the command line, and everywhere on OS X). I've always found it baffling the programs like tmux and screen override readline bindings. Shouldn't those be on the list of bindings to never override?
- Saser 11y agoIn zsh (or at least with my configuration, which is prezto with a few plugins), Ctrl-q lets you "stash" your current command. Say that you are typing some really long, complex command, and suddenly you realize that you are in the wrong folder. You press Ctrl-q (which clears the command and "stashes" it), then you cd to the right folder. As soon as you return to the prompt after issuing your cd command, your really long, complex command is back just as you typed it.
- bcl 11y agoHe missed one of the most useful commands - ctrl-b z - to zoom a pane to the full size of the window. Very handy for multi-line copy operations so you don't get other pane's content or border characters. tmux is also a great way to keep your workspace available from other machines. eg. run tmux and all your text mode clients on a server somewhere and ssh into it.
- jradd 11y agonice! To think I have been using ^-b :break-pane the entire time…
- ejcx 11y agoDiscovering tmux and finding a workflow with it that works for me made me so much more productive I have a really weird setup though. I run screen on my laptop with a window for each machine I'm connected to. An irc box, a VM, a remote dev box, and a local screen. All of these Screen Windows I have a tmux session in. I have a minima tmux config that makes resizing panes easy and fast to whatever size I want and whatever order I want. It sounds stupid but I see people using multiple iterm or terminal Windows and I don't know how they do it. It just feels so slow to me. Tmux and screen are awesome you just need to find one that works for you.
- ludwigvan 11y agoYou can also have nested tmux sessions instead of screen+tmux setting: https://mutelight.org/practical-tmux https://mutelight.org/practical-tmux " Command Sequence for Nested Tmux Sessions Often I'll run a multiplexer inside another multiplexer and need a command sequence to send things to the inner session. In Screen, this could be accomplished using C-a a <command>. This doesn't work out of the box in tmux, but can be fixed with a little configuration. bind-key a send-prefix "
- ejcx 11y agoI can but I didn't like it as much. Screen out of the box with no screenrc was exactly what I wanted. now it's kind of stuck, as silly as using screen and tmux is.
- joombaga 11y agoWhy do you use screen locally instead of tmux?
- ejcx 11y agoI use screen only to switch between servers. one of my screen Windows is a local tmux session. It's wonky
- ludwigvan 11y agoHere are some things that might be helpful for newcomers. All those tmux commands, like set, bind-key etc might be put inside your tmux.conf file, as well as executed as commands directly. For example, once you are inside a tmux session, simply execute them by prefixing with tmux: tmux set status off tmux set status on tmux set status-style "bg=red" tmux new-window tmux new-window -n "my window name" tmux rename-session mysession Of course, you can execute them outside the tmux session too, you just need to tell it which tmux you want to control. Open a new terminal, do not enter the tmux session, execute the following: tmux set -t mysession status-style "bg=yellow" tmux new-window -t mysession Inside a tmux session, tmux automatically knows which session you are talking about, so no need for "-t mysession" section. Now, I hope you get the idea, you can manipulate tmux using a client-server architecture from the outside, this is the gist of the other tools like tmuxinator. You could easily script tmux this way, so that it sets up 4 windows, one running your server, one running your db etc. What the keybindings do is, effectively to map these commands to keyboard shortcuts, you can also execute any command using `C-b :`, similar to how emacs can do `M-:`. I think tmux was in some ways inspired by emacs. Hit `C-b :', then run one of the commands, `new-window`, hit Enter. When you are satisfied with these commands, move them your .tmux.conf file. However, note that it will not sourced (read) until after you restart tmux or you source it yourself. Either quit tmux or do tmux source ~/.tmux.conf Of course, you can similarly group your project-level settings to their own configs, and source them or start tmux with those settings with tmux -f. tmux source myproject.conf (inside tmux session) or tmux -f myproject.conf (outside tmux session)
- jtw549 11y agoIs this better than putty manager?
- talideon 11y agoIt serves a different purpose: putty manager is for managing multiple SSH sessions within a single app, but with tmux running remotely, you only need one SSH session, and you can leave it running when you disconnect, which is extraordinarily useful.
- nZac 11y agoI use tmuxinator to manage all of my tmux sessions. While, I could write tmux scripts for everything the yaml format does just about everything I need. I treat a session as a project, for example mux dotfiles will open a tmux session, cd into the correct directory, and setup and panes I want when working with my config, just one. On a customer project I often have one window for vim, then another window for the server to run, psql, and any additional services I need. I have also found, prefix-s to be very helpful to switch between projects very quickly.
- deckar01 11y agoI recently stumbled across tmux while trying to provide a more customized UX in a bash script. Tmux and screen seemed a little more powerful than I needed, with lots of ways to accidentally corrupt the terminal. More and less were pretty close to what I wanted, but I could not figure out how to accept arbitrary input from the less prompt, exit, and pass it to bash. Maybe that's not what less is for. Any tips on how I can create a less UX with custom input handling would be appreciated.
- zehemer 11y agoThe select builtin might help in your case: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_06.html http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_06.htm...
- pmoriarty 11y agoCheck out rlwrap.[1] [1] - http://utopia.knoware.nl/~hlub/uck/rlwrap/ http://utopia.knoware.nl/~hlub/uck/rlwrap/
- deckar01 11y agoFor future reference, if you want to replicate a git-like man page UX (using less as the pager) the trick is defining custom commands with lesskey[0]. You can specify the exit status of the "quit" action to pass the information back to the calling script. [0] https://www.freebsd.org/cgi/man.cgi?query=lesskey&sektion=1 https://www.freebsd.org/cgi/man.cgi?query=lesskey&sektion=1
- xufi 11y agoTmux is awesome. been using it for a while but still need to learn more about it. Its great to have a progress running here and checking on it later while on another window
- airesQ 11y agoRecently I've come across the tpm (Tmux Plugin Manager), available at [0]. Happy with it, even though I'm only using two plugins: tmux-sensible (better defaults) and a theme-pack [1]. [0] - https://github.com/tmux-plugins/tpm https://github.com/tmux-plugins/tpm [1] - https://github.com/jimeh/tmux-themepack https://github.com/jimeh/tmux-themepack
- rogerbinns 11y agoIs there a good explanation as to why tmux forces all viewers to view the exact same content? I very frequently want to see different windows (or whatever the terminology is) on different connections. Screen for example allowed that by default. (I do know that you can do some complicated scheme of multiple-layers of indirection, but really why can't this just work by default?)
- lolidaisuki 11y agoI sent you an email about this that you haven't responded so I decided to also respond to you now that my very annoying shadowban messaging limit allows me to post again. There is a simple way of letting two connections view same set of windows but work on different windows simultaneously. Say you have a session named CODE and you want to view the windows in it using two connections and sometimes you want to see different things at the same time. What you can do is you can source another session from that session with `tmux new -s CODE2 -t CODE`. Now you can attach those sessions and look at different windows at the same time. This does not require "complicated scheme of multiple-layers of indirection".
- picozeta 11y agoI sometimes tried that (and used screen for some time), but it never clicked. AFAIK the only advantage to a scriptable tiling WM is the persistence thing, but I never had a use-case for that.