Some more resources for learning more about tmux:<p>- The Tao of tmux [0]<p>- A minimalist guide to tmux [1]<p>- Benefits of using tmux [2]<p>- tmux shortcuts & cheatsheet [3]<p>[0] <a href="https://leanpub.com/the-tao-of-tmux/read" rel="nofollow">https://leanpub.com/the-tao-of-tmux/read</a><p>[1] <a href="https://medium.com/actualize-network/a-minimalist-guide-to-tmux-13675fb160fa" rel="nofollow">https://medium.com/actualize-network/a-minimalist-guide-to-t...</a><p>[2] <a href="https://blog.bugsnag.com/benefits-of-using-tmux/" rel="nofollow">https://blog.bugsnag.com/benefits-of-using-tmux/</a><p>[3] <a href="https://gist.github.com/MohamedAlaa/2961058" rel="nofollow">https://gist.github.com/MohamedAlaa/2961058</a>
Tmux is another one of those tools whose siren call I'd avoided for a good decade, continuing to rely on GNU Screen. Then, for the last time I reconnected to a split screen and screen lost my splits and tabs - it was enough for me.<p>Two years ago I finally changed over and I haven't looked back. At this point, when I encounter something where I only have screen I'm rather annoyed by it - and I've set my tmux key mapping to basically mimic what I've been using screen for the last 20 years.<p>For me, tmux replaced every single feature that I used in screen. On the other hand, I'd be genuinely happy if it existed on the older OSes I randomly have to frequent, even if it's understandably impossible.
My favourite little tmux trick is in ~/.tmux.conf:<p>`bind r attach-session -c "#{pane_current_path}"`<p>All the terminals I open start a new tmux session (left as an exercise to the reader). I change directory to whatever project I'm working on, hit `C-b r` and from then on all panes and and windows in that session will start in the correct directory. Saves me a lot of cd'ing.
tmux was an absolutely game changer for me. At first I thought I was fine just being really comfortable with shortcuts and splitting commands with my favorite terminal emulators but tmux along with tmux plugins ecosystem[0] is really a world of difference, and much better.<p>I haven't gone so far as to change my default shell to tmux in the terminal emulator I use, for the sole reason that I imagine that I just don't need tmux <i>every single time</i>. In reality, 99% of the time the first thing I do when I restart my computer and open a terminal and run `tmux`, and start setting up my workspaces based on what I've been doing, naming windows, etc.<p>The top two features I use every day:<p>- keyboard-only selection + cut & paste between panes (yes, piping to xclip is good, but it's nice when you can just enter the right tmux mode, use emacs/vim keybindings to go up and copy out some text)<p>- easy/instant resizing and organizing of panes<p>- naming/breaking/moving/combining panes, to focus my efforts (something as simple as naming a window appropriately focuses my efforts inside that window)<p>An example of this is working with tools like `kubectl` that generate randomly named components that I have to list out @ the command line and do operations on, most of the time when I watch people deal with this in talks, they have to go and double-click-select or type things out.<p>[0]: <a href="https://github.com/tmux-plugins" rel="nofollow">https://github.com/tmux-plugins</a>
I find both tmux and Gnu Screen difficult to config (haven't taken the time to learn) but I love the concept of them so I use Byobu (<a href="http://byobu.co/" rel="nofollow">http://byobu.co/</a>) on top of tmux/screen to set common configuration for you. Byobu really lowers the amount of config and barrier to entry because Byobu uses common hotkeys. For example F2 for new window.
I must admit I'm a screen guy. I feel not at home when I find a system without screen and I miss the "killer feature" of connecting to any tty at any baud rate<p><pre><code> screen /dev/ttyUSB0 9600
</code></pre>
in tmux. But recently I tried to switch to tmux and found a few useful configurations.<p>1) I have alacritty as a terminal so no scrollback and no tabs (yeah there is a scrollback branch, but why duplicate functionality?) So my default setup right now is that alacritty (I use i3 so alacritty is bound to meta+enter) opens with this line (this way only one terminal can be opened and has always the same state)<p><pre><code> tmux attach -d -t alacritty || tmux new -s alacritty</code></pre>
So I got scrollback and tabs. Also I added<p><pre><code> bind-key -n C-t new-window
bind-key -n C-PPage previous-window
bind-key -n C-NPage next-window
</code></pre>
to the config so I can use it like any normal terminal with ctrl+t (new tab) and ctrl + pgup/down to switch between them. In theory I could even add shift with (C-S-t), but this somehow doesn't work for me and I found conflicting information on it and some outdated infos so I just stopped looking.<p>The second configuration that I like to use is what everybody uses<p>2)<p><pre><code> unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
</code></pre>
to change the prefix to the sane ctrl+a screen default.<p>Also setting colors is a must for neomutt and co<p><pre><code> set -g default-terminal "tmux-256color"
</code></pre>
I'm still experimenting with configs for my desktops and servers, but I'm feeling a bit more at home with tmux right now.<p>Oh and for anyone who doesn't know of byobu check it out <a href="http://byobu.co/" rel="nofollow">http://byobu.co/</a> it's a wrapper around screen and/or tmux and is easy for beginners and a nice change for everybody else.
One feature that I really like on my Mac was iTerm2's persistence (tabs and outputs preserved across reboots). This is particularly important where I live because we have frequent electric outages.<p>I now have something on Tmux with <a href="https://github.com/tmux-plugins/tmux-continuum" rel="nofollow">https://github.com/tmux-plugins/tmux-continuum</a> .<p>That's one of the best things about Tmux: there's generally a way to get it to do what you need it to do. Or something close enough.
One issue I have with tmux is that you can't resize the window to the current device. The developers seems to be very adament that it isn't implemented.<p>Currently tmux will adapt the size to the smallest (on each axis) client. This doesn't work well with persistent connections from a phone and PC since they typically have quite different window sizes.<p>In screen I hit ctrl-a + F to resize to current client and I miss it every time I use tmux.<p>Unfortunately I still prefer tmux, worth trying out if you haven't!
I use a macOS laptop with iTerm2 to connect to a remote tmux server running on Linux, and the iTerm2-tmux integration [0] is pretty great if you like multiple panes per window. I don’t have to mess with mouse mode for straightforward pane resizing, buffer scrolling, or copy/paste text in the buffer. I recommend taking a look if you’re typing on a Mac.<p>[0]: <a href="https://www.iterm2.com/documentation-tmux-integration.html" rel="nofollow">https://www.iterm2.com/documentation-tmux-integration.html</a>
I'm using tmux myself for persistent shells on remote machines (mostly irc), but not much otherwise. Lots of people and guides make it sound like it's also very useful when you're working locally. Can someone enlighten me what tmux can do for you in this case that people are so excited about it?
My tmux conf: <a href="https://github.com/EverettBerry/dotfiles/blob/master/ubuntu/.tmux.conf" rel="nofollow">https://github.com/EverettBerry/dotfiles/blob/master/ubuntu/...</a><p>I especially like prefix + & to kill the whole window, prefix + , to rename window, and prefix + ":break-pane" to split the current pane into a new window.
I like to be able to attach to my customary sessions quickly, or reinstantiate them quickly in case of reboot etc.<p>I use something like the following in my .bashrc:<p><pre><code> alias f='tmux attach -dt f || tmux new-session -s f'
</code></pre>
That way I can recreate or attach to my usual session(s) without even taking my hands off home row.
To those who use a tiling window manager: how do you incorporate tmux in your workflow? Since I've mainly used tmux to show multiple terminal sessions at once, I found it to be redundant in a tiling wm environment. But I'm sure I'm missing out on other features that my wm cannot provide.
Is it possible to have tmux allow mouse scroll in your active window? I always have to press CTRL+B to enable it which is such a pain. This is the only thing that slows me down when using tmux.
I probably know about 5% of tmux, but I freaking love it. I've had a tmux session with 12 sub-windows running on a server for 300 days. I connect to it daily, from different machines. It works. It does everything.<p>I have no desktop application that performs at this level. So my hat's off to the tmux developers. Like many other great open source tools, it's a critical part of my toolset.
I do things like:<p><pre><code> - nest tmuxes (up to three levels, with different prefix keys for each level)
- one tmux session per workspace (git clone, whatever)
- cscope on window zero of any workspace session
- use a CSCOPE_EDITOR that starts $EDITOR in a new, appropriately named tmux window in the same session, and returns control to cscope
- script the setup of my main session</code></pre>
My biggest complain about tmux is a change they made a few months ago, where they decided to show all the windows by default instead of only showing those in the current session. Even if you filter the sessions to show only those in the current session, it's still not the same way it used to be. For that reason, I have stuck with an older version. \rant
> You can detach from the Tmux session and return to your normal shell by typing:<p>> Ctrl+a d<p>Looks like someone uses 'Ctrl+a' as his personal prefix and forgot to replace it in that part of the blog post ;-)<p>Background: I use 'Ctrl+a' myself (and hate it that tmux uses Ctrl+b by default).
In tmux, is there a way to make the logical screen larger than the physical screen - so you can (1) scroll around to see the whole screen, and (2) view different parts of the logical screen in different terminals?<p>Useful for mobile devices with small screens.
Might as well take the chance to ask here:<p>Is there a way to get the count of total tmux sessions being run on any machine, for all users?<p>I can do "tmux ls" but that only returns for the current user.
Wow conveniently enough I've been trying to get started on a Tmux & Vim environment and I've been running into walls on Tmux related guides.
I only started using tmux like half a year ago, and now it is the first thing I start when opening my terminal.<p>Really improves development with cli tools.