9 ms·
Use fzf for tmux session switching
- deleted 4y ago[deleted]
- kentor 4y agoVideo is cut off on mobile
- stingraycharles 4y agoYes I had the same, after about 2 minutes things became weird and cut off. Seems like a transcoding error for certain devices only then, if nobody else noticed it. Unrelated, but it was completely impossible for me to put the video on full screen. It seems like the site did something with the scroll that prevented me from scrolling horizontally to click the full screen button.
- rablackburn 4y agoThe 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.
- 1vuio0pswjnm7 4y agoIt 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.
- nickjj 4y agoI use it to manage my dev environment with a bunch of sessions. One for my blog, podcast, 2 side projects, contract work, etc.. I usually have 6-10 sessions. Although I don't use fzf to search through them. The built in leader+s key makes finding and jumping between sessions painless, you also get the benefit of being able to see a preview of what's in the session.
- jbranchaud 4y agoI 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.).
- hyperpl 4y agoIf 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.
- deleted 4y ago[deleted]
- ivank 4y agorpick() { 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 }
- a-dub 4y agotmux 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 buffers and mousing and such are preserved)
- CraigJPerry 4y agoModern ssh supports forwarding of Unix domain sockets On remote host: $ tmux -S /tmp/remote.sock <now detach from session: prefix d> 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
- maxdamantus 4y agoHave 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
- CraigJPerry 4y agoI hadn’t, i just tried it now and yeah it doesn’t work :thumbsdown:
- pm90 4y ago+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.
- linsomniac 4y ago
- clvx 4y agoNice, I just extended this to kill a session too. This is great.
- stevebmark 4y agoI 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
- gazby 4y agoThe only macOS app I miss on Linux
- cassianoleal 4y agoiTerm2 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.
- maheart 4y agoI've wanted something like this but for "screen" for a long time. Does anyone have such a solution?
- ray__ 4y agoI 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?
- rodorgas 4y agoOn Vim there's a plugin called Vimux which allows me to control other pane from Vim. For example, I type `<leader>l` and it runs the last command on the next pane, which usually is a command to test the code I'm working on. Sure, you can do everything in a WM or DE, but I use Linux and macOS and it's nice to have the same configuration, keybindings and environment everywhere. I also find tmux more customizable than Gnome Terminal and easier to setup than st or urxvt.
- sureglymop 4y agoYou 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.
- ladberg 4y agoI’m a huge fan of `tmux -CC` for stuff like this!
- jgtrosh 4y agoI didn't know about this. For others, it's called tmux control mode, and integrates tmux within a terminal emulator for things like split panes and tabs. It requires terminal emulator support. Here's some documentation: https://github.com/tmux/tmux/wiki/Control-Mode https://github.com/tmux/tmux/wiki/Control-Mode
- cryptonector 4y agoI'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.
- silves89 4y agoAnother 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.
- bazhova 4y agoYour 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!
- yourapostasy 4y agoI'm still trying to assemble a way to put together the pieces to not only return to tmux sessions after detaching, but after detaching and the underlying server reboots. Playing around with CRIU, but trying to make it all automagic with nested PIDs, restore the screens and shell history buffers just how I left them, and implement the common use case of automatically re-establishing ssh connections remains a challenge.
- davvid 4y agoI've never used this myself, but you're describing what a coworker used to recommend when that topic came up many years ago. See the bottom of this page about byobu. https://help.ubuntu.com/community/Byobu https://help.ubuntu.com/community/Byobu I'm sure there are newer/better? tools someone might recommend here too.
- dbdoskey 4y agoIf you like tmux, take a look at zellij (https://github.com/zellij-org/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".
- RMPR 4y agoUnless there's something like byobu, I'll stick to tmux for the time being.
- ninjin 4y agoInteresting, reminds me of dvtm [1]. But I am sure there are more takes out there on “window management” in a terminal as I have not really explored this space much. [1]: https://github.com/martanne/dvtm https://github.com/martanne/dvtm
- obiwanpallav1 4y agoFor layout in Tmux you can checkout https://github.com/pallavJha/chaakoo https://github.com/pallavJha/chaakoo too.
- AlecSchueler 4y agoWow 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!
- anelson 4y agoI 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/bin/ftwind https://github.com/anelson/dotfiles/blob/master/home/.local/... EDIT: for formatting
- pkrumins 4y agoOnce I discovered fzf a couple of years ago, I instantly knew it was the future of shell. My entire workflow is now driven by fzf. I use it together with bash, vim, cd (and "z" command), even mkdir (autocomplete from "words" file).
- RMPR 4y ago> and "z" command I use zoxide now, it's slightly faster.
- cptnapalm 4y agoCould someone, in brief, tell me what fzf actually is. The man page is uninformative.