Live data from Hacker News

Use fzf for tmux session switching

waylonwalker.com

41–50 of 61 posts

Re: Use fzf for tmux session switching

#41

If you like tmux, take a look at zellij ( https://github.com/zellij-org/zellij ), it is a modern alternative that has a lot of nice features (either developed, or on the roadmap) that tmux is missing. Have no relationship to it, just a happy "customer".

For layout in Tmux you can checkout https://github.com/pallavJha/chaakoo too.

Re: Use fzf for tmux session switching

#42
post #30

Earlier quoted context omitted.

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!

Are there any Linux terminal emulators that implement this? So far the only I've encountered is macOS's iTerm 2 and it's brilliant but mac-only.

Re: Use fzf for tmux session switching

#43

I really like iTerm2 for Mac. The tabs, splits, and navigation, are intuitive and powerful. I haven’t found a need for tmux. I use fzf for file finding, it looks like this is use is a subset of iTerm2 capabilities

iTerm2 has `tmux -CC` compatibility. That means when you SSH into a server over iTerm2, you can type that command and get tmux integrated with iTerm, with all the regular window splitting, resizing, tabbing, etc working natively on the terminal emulator.

Essentially you get all tmux functionality on the remote but with the local ergonomics you're already used to.

Re: Use fzf for tmux session switching

#44

If you like tmux, take a look at zellij ( https://github.com/zellij-org/zellij ), it is a modern alternative that has a lot of nice features (either developed, or on the roadmap) that tmux is missing. Have no relationship to it, just a happy "customer".

Wow this is the first time I've ever seen a comment that genuinely made me feel like an old gray beard.

I remember getting into Unix just a little before the time tmux came onto scene as the modern alternative to screen, and being in awe of all the people who had used screen long enough to have a list of things that could be modernised about it.

Now tmux is in that position!

Re: Use fzf for tmux session switching

#45

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 sing…

Your last point is why I use it. I think many don't know you can configure it to open apps, run commands, and open splits on start. Super helpful when projects get big!

Re: Use fzf for tmux session switching

#46
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…

One of the first reasons I starting using screen (switched to tmux later) for local terminal work was so I can re-open it if I accidentally closed the window. It's still one of my reasons for using it.

Re: Use fzf for tmux session switching

#47
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 do everything from the keyboard. No need to ever reach for the mouse. Ever. Once you master it (the learning curve is a bit steep though), you'll never want to go back. I do use my own customized key-bindings.

Also - for long running processes, you can run stuff in a tmux session, go to bed, and wake up hours later and see exactly what happened. You can make the scrollback buffer as big as you want. My scrollback history is 50k lines, and that's totally fine. Of course the history is searchable with vim commands which is also nice.

Re: Use fzf for tmux session switching

#48
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…

Isn't this just:

$ ssh

$ tmux --list-sessions

and

$ tmux --attach-session -t

?

Re: Use fzf for tmux session switching

#49
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…

This is exactly my set up as I work on a number of remote systems daily.

I have an "outside" tmux session that can be run at either my desktop or laptop. When I start fresh, I open an outside tmux session and run a startup script. This preloads my outside session's copy buffers with named passwords from the `pass` password manager and creates windows to each of my remote sites. The shell for each of these windows is set to a script that does a simple loop of network check than attempt to ssh to the remote site. This ssh connection has an environment variable set that my remote bashrc will see. When this variable is set, my remote "inside" tmux connection is automatically recalled (or created if it doesn't exist.)

I have a script runs when I put the laptop to sleep that kills all the SSH connections cleanly, and when it wakes up again, every window reconnects to the remote machines and opens the remote tmux connections again. Everything is exactly where it was before and needs no intervention.

Re: Use fzf for tmux session switching

#50
I had this problem myself when using tmux (how to switch sessions quickly and easily).

I ended up writing a shell script [1] to use fzf to display a list not only of sessions, but the windows within each session.

Which I invoke from tmux like this:

bind C-a run-shell -b "$HOME/.local/bin/ftwind"

This has become so ingrained in my tmux workflow that I would be utterly helpless without it.

[1]: https://github.com/anelson/dotfiles/blob/master/home/.local/...

EDIT: for formatting

Post reply on HN