Live data from Hacker News

Use fzf for tmux session switching

waylonwalker.com

21–30 of 61 posts

Re: Use fzf for tmux session switching

#21
I still don't quite understand the value of tmux, at least on a modern machine. If I need another terminal, I just pop open another terminal window and tile or tab it. If I want to keep a set of terminals organized, I use workspaces (at the OS level).

I can obviously see its value if there is no window manager or desktop environment on the system I'm using, but that's rare these days–if I'm working on a system with neither of these it's always over ssh. With a WM or DE it seems like tmux just adds a redundant layer of organization. What am I missing?

Re: Use fzf for tmux session switching

#22
post #6

tmux sessions are incredibly useful for keeping multiple projects organized. i just wish i could connect to remote tmux back ends and recover windows as organized locally after a network cut. so the local tmux presents the ui and performs session management, and the remote tmux backends hold the shells to provide network cut resilience, but still rely on the local ui instance for all user interaction (so cut/paste bu…

Can you elaborate further on what gain I would have by having the tmux UI "rendered locally" on my system vs the SSH host? I'm obviously missing something based on your description. For example: SSH into server, start tmux on that system. If I am disconnected for some reason, SSH back into server, tmux attach -t 0 (or whatever ID I have) and I've recovered my session. Cut/copy/paste, mouse use, etc., are all treated…

a sibling comment suggests a reason:

> the local tmux then remembers history and allows looking up commands on the remote shell, that would be huge.

Re: Use fzf for tmux session switching

#23
I've a much simpler solution. I nest tmux sessions. In the top-level session every window is named the same as the session that is attached in it. I've two different prefix keys: ^T for the top-level, and ^A for the level below. Plus I've a one-liner (well, shell function) for mapping PIDs to session & window. Plus a script to create new nested sessions, and a script start $EDITOR in a window of the current session (with the window named after the file being edited). Plus I've a half-baked script to set up this environment, with one nested tmux per-project.

This allows me to have a very well-organized way of working over ssh.

Re: Use fzf for tmux session switching

#24
post #21

I still don't quite understand the value of tmux, at least on a modern machine. If I need another terminal, I just pop open another terminal window and tile or tab it. If I want to keep a set of terminals organized, I use workspaces (at the OS level). I can obviously see its value if there is no window manager or desktop environment on the system I'm using, but that's rare these days–if I'm working on a system with n…

You can ssh into a system and use tmux. Then you can detach from the session and when you come back a week later your tmux session is still there and you can continue with no friction. Also i find it interesting that you said you don't see its value and then continued to explain its value. For me it's definitely more common to work with systems/servers without a DE and WM. It's just better to handle this problem at that level instead of at the terminal level because then your shell setup becomes terminal and platform agnostic. With mouse support turned on tmux feels almost like a WM in the shell, which is amazing.

Re: Use fzf for tmux session switching

#25
post #21

I still don't quite understand the value of tmux, at least on a modern machine. If I need another terminal, I just pop open another terminal window and tile or tab it. If I want to keep a set of terminals organized, I use workspaces (at the OS level). I can obviously see its value if there is no window manager or desktop environment on the system I'm using, but that's rare these days–if I'm working on a system with n…

Imagine you're at work, and you have tmux running with 15 sessions to various machines. You go home, connect to that tmux session and you can keep working without having to re-connect/SSH and log into 15 machines and just continue where you left off.

It's sort of like being able to RDP into the machine you were working on except it's text-based.

Re: Use fzf for tmux session switching

#27
post #6

tmux sessions are incredibly useful for keeping multiple projects organized. i just wish i could connect to remote tmux back ends and recover windows as organized locally after a network cut. so the local tmux presents the ui and performs session management, and the remote tmux backends hold the shells to provide network cut resilience, but still rely on the local ui instance for all user interaction (so cut/paste bu…

6 months or a year ago I started using "mosh" to connect to my main machine from my laptops, and I run tmux on that machine. When I have a network cut, I just wait a few seconds and it's back in business, whether that's moving locations (I use a VPN so my IP is always the same, currently Nebula but has been wireguard and ZeroTier in the past), legit network problems, switching to my cell phone...

i've done this with mosh in past which gets you part of the way there.

problem is that it then doesn't work for local sessions. so you run it locally, which gives you local sessions and window management, but then all remote connections have to be via mosh -or- you mosh into the datacenter which is good for accessing infra, but leaves you having to run a separate instance for local work.

Re: Use fzf for tmux session switching

#28
post #21

I still don't quite understand the value of tmux, at least on a modern machine. If I need another terminal, I just pop open another terminal window and tile or tab it. If I want to keep a set of terminals organized, I use workspaces (at the OS level). I can obviously see its value if there is no window manager or desktop environment on the system I'm using, but that's rare these days–if I'm working on a system with n…

Imagine you're at work, and you have tmux running with 15 sessions to various machines. You go home, connect to that tmux session and you can keep working without having to re-connect/SSH and log into 15 machines and just continue where you left off. It's sort of like being able to RDP into the machine you were working on except it's text-based.

So something like abduco (https://www.brain-dump.org/projects/abduco/) should do the job too? I think GP's comment was more concerened with the terminal multiplexing, not the ability to detach a session.

Re: Use fzf for tmux session switching

#29
Another reason for using tmux: never worry about changing your muscle memory for splits and nav ever again.

I've been using tmux for five or six years. In that time I've used Linux and MacOS and several different terminals. But how I navigate around a terminal has stayed the same thanks to tmux.

Another reason: put complex tmuxinator configs in source control and start up a bunch of stuff for your project with a single command.

Re: Use fzf for tmux session switching

#30
post #21

I still don't quite understand the value of tmux, at least on a modern machine. If I need another terminal, I just pop open another terminal window and tile or tab it. If I want to keep a set of terminals organized, I use workspaces (at the OS level). I can obviously see its value if there is no window manager or desktop environment on the system I'm using, but that's rare these days–if I'm working on a system with n…

You can ssh into a system and use tmux. Then you can detach from the session and when you come back a week later your tmux session is still there and you can continue with no friction. Also i find it interesting that you said you don't see its value and then continued to explain its value. For me it's definitely more common to work with systems/servers without a DE and WM. It's just better to handle this problem at t…

I’m a huge fan of `tmux -CC` for stuff like this!
Post reply on HN