Note that I have been using text-only terminals since the 1980s, but I've adapted my tty usage over time.
The problem that tmux (or screen) brings are first and foremost:
* Smooth/fast scrolling goes away. I can no longer give my trackpad a slight push to find myself tens or hundreds of lines in the scrollback history, and visually scan by slightly pushing my fingers back and forth. Instead I have to use the horrendous in-tmux scrollback using "Ctrl-b [".
* My terminal app's tabs and windows are not tmux's tabs and windows. I cannot freely arrange them in space, snap them off with the mouse, easily push them to another desktop, and so on. I have to start a multiple tmux clients and do awkward keyboard interactions with them for any of the same.
* tmux's terminal emulation and my terminal emulator's terminal emulation (heh) are not congruent. As a result, programs cannot make full use of my actual terminal's capabilities. For example selecting, copying, and pasting text sometimes behave weirdly, and there are other annoyances.
What I'd really like to have instead is terminal session management at a higher level, i.e. involving my actual graphical terminal app itself. Attaching to a running session would mean restoring the terminal app's windows and tabs, and the entire scrollback history within (potentially with some lazy loading).
tmux could likely be a major part of that, by providing the option of replacing its tty-facing frontend with a binary protocol that the graphical terminal app talks to, while keeping the backend (i.e. the part that provides the tty to anything running inside it) the same as it is today.
As it is, the downsides of using tmux all the time are too high.
That was the first thing I looked-up how to fix (years ago). Put the following in your tmux.conf:
set -g terminal-overrides '*:smcup@:rmcup@'
set -g status off
https://iterm2.com/documentation-tmux-integration.html
Other terminal emulators offer similar features to Tmux. For example, Kitty claims to support Tmux's features outside of remote persistence.
Yeah, copying can be weird. I full screen a panel to copy multiple lines of text using the terminal emulator’s copy, not tmux’s. Works well enough.
I think there are/used to be some mice with a ultra-low-fricton "freerunning" scroll wheel. I guess that could be a similar experience, but of course tmux would stand in the way of that as well.
And I'm very old school and had been using text-only terminal starting in the 1980s...
I just tried your config setting in Ghostty and still, when I use my mouse it scrolls through zsh history, not the screen
When you enter tmux scroll back buffer with "Ctrl-b [" you can reverse search the entire output and navigate within the buffer with standard shortcuts (same as man pages). I also added this yank plugin to copy any highlighted output to my system clipboard. Makes searching and copying output super fast
For me, customized Vim search is just miles ahead of everything else so I prefer that (not just for the search, but also to open files with gF, etc.).
I also have a couple binds in Vim to deal with tmux:
vnoremap <leader>ty "ty:call system('tmux loadb -', getreg("@t"))<cr>
nnoremap <leader>ty "tyiw:call system('tmux loadb -', getreg("@t"))<cr>
nnoremap <leader>tp :let @t=system('tmux showb')<cr>"tP
Do you mean something like Xpra, x2go, NX, VNC, or Parsec?
Is this an inherent limitation of multiplexers or does it stem from a choice made by tmux?
To change that behavior, put the following in your tmux.conf:
set -g terminal-overrides '*:smcup@:rmcup@'
set -g status off
I just wish Terminal.app had vertical splits and true colors. It’s just embarrassing that Apple hasn’t touched it in such a long time. I’ve been looking for a better terminal emulator for years and tried pretty much all of them, but begrudgingly end up back at Terminal.app
- env KUBECONFIG=$HOME/.kube/setup-1 tmux new -s setup1
- teamocil: https://github.com/remi/teamocil#readme (MIT)
The first one I use for circumstances where I want to investigate a lot of different things in a dedicated cluster, without the hassle of having $(kubectl --kubeconfig ...) or the risk of k() { kubectl --kubeconfig ... "$@"; } and losing track of what context I'm in[1]. Because, with iTerm2's integration command-n or command-t opens a new window or tab but with retaining the credential scoping. If I need to change scopes, I can just detach from the tmux session, attach to a different one, confident that I don't have any variables to unset
The second I use in "standard" setups where I want to view the same configuration every day (say: web, api, database pods). Having teamocil allows me to either have those same commands laid out in the same pattern as yesterday, or I've also had pretty good luck just generating the yaml files because their syntax is simple enough
1: related to that, if you haven't seen it, iTerm2 offers the ability to set the RGB of a tab via OSC: https://iterm2.com/documentation-escape-codes.html#:~:text=t...
Likewise i enable vim keybindings, mouse mode, and if you use a Mac and iTerm selecting text will automatically drop it into your clipboard ready to paste.
I tend to make use of the following command - which will output the last 100000 lines of the current pane to a text file local to you; it’s useful for documenting screwups, maintenance work, and of course making notes on what you’ve done for future reference
> bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S -100000 ; save-buffer %1 ; delete-buffer'
When I learnt tmux, I had to access multiple VMs which were de-facto ephemeral, which meant customization was not an option anyway. I kind of learnt to like the defaults as they are.
My favorite tmux command from the shell is: "tmux new -A -s me", which I have aliased to "tm". It creates a tmux session named "me", or attaches to a session named that if it already exists.
I am aware of tmux, dvtm, zellij, and GNU screen. That's it: just 4.
Has anyone written a comparison of them? I would be genuinely interested. I personally favour ease of use over features.
It is sad that it has not been maintained in a while (written in rust) as I much prefer the low cognitive load approach it presents (just fuzzy find) as well as the workspace feature.
Would be interested in knowing if there is something similar and maintained.
P.S. Does anyone here know how to make GNU Screen start up by default on a terminal launch?
IMHO <https://cfoust.github.io/cy/replay-mode.html#:~:text=make%20...> is trying to drive down the risk of an Evil Operator reading my files as if it's the 90s at school but my modern risk is that some npm dependency exfiltrates the .borg files, which are readable by me, to North Korea. I was hoping to find an encryption option but did not
> Configuration: cy uses a real programming language, Janet, for configuration.
Man, why everybody gotta reinvent scheme? https://janet-lang.org/#Code-Example
I do like any app with a command palette though https://cfoust.github.io/cy/quick-start/command-palette.html
It's a tiny bit more scriptable, but it's not like a real API either.
How is it less capable?
With screen, I can have windows 0 and 1 in a vertical split on my laptop, and windows 0 and 3 in a horizontal split on my desktop.
With tmux, you attach to a session and it has the same layout everywhere. You can have attach different servers or different sessions but you can't even show different windows in the same session, let alone have different layouts. If my laptop shows window 1 containing 2 panes, my desktop can only show window 1, and it will contain 2 panes. Changing the layout or the active window will change it everywhere.
I simply deplore that the tmux developers obviously thought long and hard about this design only to come up with something needlessly complicated and in the end less capable than screen's model (since you can't have different clients with the same windows in different layouts).
I use screen, but whatever I have read till now on comparison seems to point more to personal preferences.
For me, it's because it's more common to use tmux and you can find from legacy configs to modern ones. So, for me, that I have not studied IT (and now I work as a programmer) it's essential to find basic configurations all over the place to have an anchor.
But, as always... Use whichever works for you. Don't think in the "best" or the "most efficient" which is just youtube propaganda. Use whichever works for you and makes you feel like home. If that's 98's microsoft word... then embrace it and be proud to have an opinion.
1. if I start something which will run for a long time and/or the connection is unstable, I start a screen session on the remote node and start the program in it
2. if I want to check something (i.e. tail -f foo.log) on several servers at the same time, I start tmux on my machine, create 2,3,...,N panes and in each pane I ssh to the 1-1 remote server and start tail -f foo.log there. So I'll see the logs at the same time on several servers, just like if I had 1-1 monitor for each remote server.
I find screen to be more stable than tmux but can't say I had any issues with tmux in the past couple of years (but it bothers me that tmux sessions share the initial environment the first session was launched from iirc). Right now it's the clipboard support that makes me use tmux over screen.
It does do this, but I am curious what would be better? I heard this complaint before and It baffles me. let me explain.
environments are... sticky, a child process inherits it's parent processes environment. so the tmux server starts and inherits the environment from the shell that started it, then each pane inherits the environment from the tmux server. As far as I can tell you want each pane to inherit the environment from somewhere else but can't figure out why or how that would happen.
My best guess is that you want tmux-attach to stash the environment it was ran in so that tmux could then use that when making new panes. my second guess is that you want tmux to use the current pane as the parent process for a new pane. both of which sounds like it would be even harder to control the tmux environment.
In fact I was a bit surprised that .profile ran on every created pane, as naively I would not have thought that would be a login shell.
not sure about the rest, I did read the man page again, and wow there is a lot more configurabilty than I first thought, however I found nothing great, the best I could come up with is.
bind c 'source-file /home/xxx/.tmux.conf; new-window'
1. Set the prefix key to C-Space. Much easier to type then any letter, and (in my case) only collides with Emacs set-mark. Its easy to remember and just type C-Space C-Space in that case.
2. Set IC (insert key) as prefix2. If you have a full-size keyboard, you can now scroll up by pressing insert (on the block of 6) and pageup. Easy to type.
3. Using sessions for ssh hosts. Add ControlPersist and/or AddKeysToAgent to ~/.config/ssh and bind the following to some key. Pressing that key will prompt for a hostname, and create a new session named after that hostname. The default-command will make it such that Prefix c will open a new window which is already logged in on that host. Its not the same as running a remote tmux, as your windows/session will not persist on the remote host, but it avoids nested tmux. I use it all the time during a typical day...
command-prompt -p "Secure Shell ([user@]host):" { new-session -A -s "%1" "ssh %1" ; set-option default-command "ssh %1" }
# ~/.tmux.conf
set-option -g prefix C-a
Edit: Oh hey, https://superuser.com/questions/74492/whats-the-least-confli... is a whole discussion of options
I would have to move my whole hand over to the arrow keys, or I can use the edge of my right hand (on a full size keyboard, not laptop) to hit ctrl, and hit "b" with my left index finger.
1) Some keyboards don't have it, or have it in an awkward place. Most Android on-screen keyboards don't have it (good time to plug Hacker Keyboard). The gestures on Blackberry (e.g. Android) physical keyboards act like scroll-wheel movements rather than cursor keys.
2) Some shells/systems/terminal emulators/some TERM= settings/etc. just don't handle cursor or home/end keys in the console, and instead splat out garbage like: ^[[C^[[D^[[7~^[[5~
Of course, a bad setup is a bad setup, and if you're moving your hands a lot because your workspace is poorly setup, you'll also have issues.
For best results, you'll want to keep your hand movements natural and comfortable and your tools within easy reach. Take short breaks to move your hands, as well as your entire body.
C-b requires me to move my whole hand to reach both keys with my left hand.
Thus: C-a wins
No need for that character 99% of the time, and hitting two in a row will still send it anyway
also works great in combination with `set -g base-index 1` so that switching between the first 9 windows can be done naturally, with `-1, `-2, etc.
Wider shell compatibility is a good reason to use backticks. Avoiding nesting is always possible. Quoting may be a concern in more complex usage. But yes, I know well, and often also use $( ) syntax.
Making a lot of noise about use of (the shellcheck author's) non-preferred syntax, which works perfectly fine in a given context, is a design flaw that renders shellcheck useless to me. I'm perfectly capable of finding an opinionated pedant on my own who will also critize the syntax I use (with little or no justification), and offer no actual help...
I changed the Keybindings for splitting and moving around terminals to be as in Emacs, and I am very happy.
https://gist.github.com/alyandon/b19e2634fac6505bb5bd0e0c99d...
Yes - I'm a terrible person.
Use ssh.
Every time the connection blips you lose the shell.
Very annoying.
Look up how to prevent that.
Learn about tmux.
Use tmux on remote shells to keep sessions up after you log out.
Neat.
Apparently tmux has sessions and panes and stuff, I could have multiple projects open in different sessions. I could have different logs and commands running in different panes.
Neat.
Hey, this is great. I should install tmux on my personal machine.
Hey, I love having multiple sessions and panes and stuff, but now when I reboot my computer, all my tmux sessions and panes are gone.
Learn about tmux-resurrect and tmux-continuum which will save the sessions periodically and automatically reconstitute them after reboot.
Extremely neat.
~10 years later and I still have all the "same" tmux sessions open, and they all have names, saved pane layouts, and histories intact.
When i encounter repetitive/manual state i need to circle back to, ill make scripts or custom configs to replicate it (nix is fantastic for that). My workflow allows sessions to close on disconnect or shutdown which brings the benefit of not relying on remote tmux installations.
Chances are, you carry around alot of implicit state. How do you backup?
Thank you. I sometimes put off reboots longer than I should simply because I don't want to lose my local tmux sessions. Maybe I don't have to do that anymore.
i have splits for dev, splits for building and testing, splits for sandboxing -- it allows me to multi-task with more screen real estate than using something like vscode or vstudio or some other conventional IDE.