Live data from Hacker News

Use fzf for tmux session switching

waylonwalker.com

11–20 of 61 posts

Re: Use fzf for tmux session switching

#11

It is interesting how much people use tmux for working in several interactive shells at once. I tend to use tmux more for running servers in detached windows.

I tend to use one tmux session per project. I usually have 2-3 open for various client projects, one open for my TIL repository, and then I go from there. Within those sessions I tend to have separate windows and panes as a way of organizing any (web) servers and other long-running processes. The 'first' window of each session is usually a split between Vim (where I'm working) and zsh (where I'm executing git commands, running tests, etc.).

Re: Use fzf for tmux session switching

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

Modern ssh supports forwarding of Unix domain sockets On remote host: $ tmux -S /tmp/remote.sock On local host: $ ssh -L /tmp/local.sock:/tmp/remote.sock user@remote $ tmux -S /tmp/local.sock attach I Typed this on a phone and not validated but it looks good to me right now

Have you tried this before? As far as I can tell, tmux expects to pass the client's terminal fd over the unix socket. When I try it, I get something like this in strace (passing fd 7):

  > sendmsg(5, {..., msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[7]}], msg_controllen=24, msg_flags=0}, 0) = 16
And then the client relays an error:

  > open terminal failed: not a terminal

Re: Use fzf for tmux session switching

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

+1

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

Currently all my local work is saved but ssh into another machine? All that work is lost forever unless I explicitly save it.

Re: Use fzf for tmux session switching

#14
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...

Re: Use fzf for tmux session switching

#15
post #3

Video is cut off on mobile

The entire site is weirdly mobile (or perhaps just mobile Safari) unfriendly.

The home page also has some issues with elements clipping/overlaying and not registering clicks.

I say weirdly unfriendly because the graphic design is very $CURRENT_YEAR, which is usually designed mobile-first (since that’s where most of the traffic is these days). But the author clearly spends more time on the desktop (the article _is_ about tmux) and didnt check how it performs on mobile.

If it is just a safari issue I’m sympathetic. Testing for safari is a nightmare if you don’t have Apple hardware available.

Re: Use fzf for tmux session switching

#17
post #5

If this tmux-fzf setup could be augmented to perform preview and grep not only on window name but also window contents then I'd consider migrating from the already built-in `choose-tree -Zw` command.

    rpick() {
        session=$(for i in $(tmux list-sessions -F '#S'); do
            echo -e -n "$i\t"; { { tmux capture-pane -p -t "$i" | tr '\n' ' '; } || true; }
            echo
        done | fzf --exact --reverse | cut -f 1)
        if [[ "$session" != "" ]]; then
            tmux attach -t "$session"
        fi
    }

Re: Use fzf for tmux session switching

#19
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 as they are through any SSH session.

Post reply on HN