9 ms·
Customizing tmux
- sjbr 1y agoyou could also use Oh my tmux!: https://github.com/gpakosz/.tmux https://github.com/gpakosz/.tmux
- EPendragon 1y agoI have checked it out initially. It hd a good set of defaults. I didn’t like everything that came with it, but I did read through its config file and borrowed a couple of lines from there into my own setup. IMO the problem with using a prebuilt config like that is that it requires you to learn all of its keybinds, styling, layout. I would rather build my own incrementally but have a sense of knowing everything that is going on in my setup.
- moontear 1y agoCame here to post the same reference. The good thing about this repo is that you can configure everything in the .tmux.conf.local. I have this synced to all my machines using syncthing and symlinks to the user directory. I also have my own keybindings, styling etc. - but this is an awesome base to get started.
- benrutter 1y agoI love tmux! Using it as a tool suddenly enabled me to do so many things. Lately I've been using Zellij, which I'd massively recommend for anyone not wanting to do a load of customisation. It just works great out the box (but probably has less wiggle room to "make your own") https://zellij.dev/ https://zellij.dev/
- EPendragon 1y agoI will definitely check it out. Thanks for the suggestion! What would you say is different between tmux and Zellij, and why did you start using the latter?
- imcritic 1y agoAnother ex-tmux user here: for it was text selection with mouse without extra line breaks, introduced by line wrapping when long strings are rendered.
- EPendragon 1y agoI gotta admit that the initial experience in copy mode in tmux made me cringe a lot. The fact that scrolling up scrolled through the history of the terminal's commands was the most unexpected thing. After I enabled mouse use, it became usable for me.
- benrutter 1y agoIf you've used Neovim vs Helix, I'd say the comparison is pretty close. Tmux is more customisable, but a lot messier out the box. It's much older so has picked up a little cruft along the way. Zellij is newer so has the benefit of being a clearer implementation. But it's designed as an "out the bix" experience, not one you can customise to your hearts content. Edit: if you did want to try out zellij, I should point out there's a "no install, try in shell" option on their website's main page which is a super quick way to get a taste!
- EPendragon 1y ago> Tmux is more customisable, but a lot messier out the box. I have definitely felt that. Customization wasn't necessarily straightforward - just required some time spent reading the docs. I appreciate the heads up about the "no install, try in shell" option. I will make sure to take a look!
- diffrinse 1y agoYou can't rebind plugin key maps and creating a new session conflicts with my preferred custom mode bindings. It's clear the devs are both rather opinionated and want to ship features, but they gotta clear stuff like that up, I'm not interested in doing that from CLI when tmux does this without issue.
- EPendragon 1y agoI feel that “make your own” has been the major driver behind looking into the configs myself. Learning other configs feels like a chore. I would rather learn and make it as I go. In the end I will have a sense of complete ownership. I will know what needs to change if I decide to change it. I think investing time into making your own wins in the long run.
- mikepurvis 1y agoThe article is focused on interactive use, but I would be interested to also hear from folks using tmux as a process manager / dashboard for server-type environments. I was pretty unenthused about this practice when I first encountered it, but it's grown on me as a way to quickly get a sense of state from onboard a running system without having to rely on off-board dashboard or log parsers / alert systems. In particular, I'm curious about libtmux/tmuxp and how well it works to have a more declarative bringup than just a bash script launching things into the background and then attaching tmux windows to them. And I guess the broader question of whether this approach is an evolutionary dead end— like does it just become a pile of hacks as one discovers the need for restart policies, backoffs, ordering, whatever other stuff that is built into a "normal" process manager like systemd or runit? If you do end up wanting to send process stdout/stderr elsewhere or do alerting, is that now annoying if those streams are "trapped" in tmux sessions vs being written into log files or the journal?
- kachapopopow 1y agoyep, that's how roughly 99.99% of major minecraft servers are ran up to this day. (and I hate migrating them)
- Filligree 1y agoSystemd just does a poor job giving you a TTY on demand.
- hnlmorg 1y agoI’ve seen people use this approach (and screen too) but personally I hate it for anything other than services that are interactive but you want detachable. Eg long running installs. All the other examples I’ve seen where people have used it as a shortcut for daemonizing a service, it’s felt like just as much effort as writing a systemd service file. I guess I could forgive people more back in the days of sysv-style initd. Writing those shell scripts was seldom fun. But with systemd, it’s literally a 5 minute task. And I say that as someone who dislikes numerous decisions made regarding the approach systemd takes.
- godelski 1y agoSo many people miss the point of tmux. The only reason to still use tmux (or screen) is because you use remote sessions. All modern terminal emulators are already capable of doing tabs and panes (okay, maybe not sessions, but some can locally). If you're using tmux for this reason, stop. Go pick up a modern terminal like ghostty, Alacritty, or WezTerm. But why tmux still exists today is because people are working on computers they aren't sitting in front of. Because I don't want to have to be running nohup or detaching, moving to the background, and resetting the session so error messages don't appear in my active instance. Hell, technically I can do this with vim and get something pretty similar to tmux by using the terminal. But that's a pain. Tmux is for *terminals*
- EPendragon 1y agoFor me tmux ended up being the solution for my dev needs. With a little bit of time, I learnt the ropes and became more or less productive with the default setup. Afterwards, I made it my own. Like you mention, tmux sessions was one of the biggest features that I enjoyed about this tool: it does the job and does it well. Aside from that I love that I can use Vim-bindings with it, that it feels very similar to Neovim for me, so using them together is a no-brainer. Learning a couple of specific keyboard shortcuts is all it takes to make me productive. I haven't needed to use a remote session yet like you note. While working with tmux locally I have learnt about all of these other features that I will definitely be looking forward to using once the opportunity arises. I don't doubt that tools like ghostty, Alacritty, or WezTerm are great. I have heard lots about the first two. And I do intend to check them out. What would you say is your favorite terminal and why as it relates to local development experience use? Are there features that these tools have that tmux lacks?
- godelski 1y ago> What would you say is your favorite terminal So far, ghostty. I do also like Alacritty and WezTerm, and think kitty is overhyped (and Warp is a privacy nightmare). A thing I really like about ghostty is it is incredibly easy to maintain. By far my smallest config file. Basically my theme and a few custom bindings. To be honest, there isn't a huge difference between all of them, with some being better at one thing than another, but I think ghostty gets things good all around. Btw, vim bindings should already be available in your emulator, without the need for tmux. You can set bash to use them (set -o vi) but I suggest migrating to zsh if you like using the cli. I'll also give you one fun command most people don't know. While holding control, press x then e (if you are already using zsh you might need to add `zle -N edit-command-line` to your rc file but <C-x><C-e> needs no config in bash). I guess I should also mention that in vim you can open a terminal (:help term) > why as it relates to local development experience use? All these emulators can do, locally, everything tmux can do and more. You just have to remember that a session is the same thing as a window. All these emulators have tabs and splits. So there is no real advantage to tmux. > Are there features that these tools have that tmux lacks? First off, switch because your emulator is probably more resource intensive. It may also be missing modern features like being able to view images (see sixel, chafa, or the kitty graphics protocol), ligatures, and a lot of other features. Second, tmux lacks many of these modern features. Doing a passthrough can help but dealing with images is not a great experience. I have found no configuration where I can reliably view images and never have been able to produce images of the same quality. I always drop out of my session if I am entering a file browser like yazi or fzf (I'll use fzf but it limits the capabilities of previewing).
- triyambakam 1y agoSetting a single key as my leader 10 years ago has been really nice. Personally it is back tick for me, but space is probably a good one too.
- EPendragon 1y agoFor me, I use Spacebar as a leader key in Neovim, so I think they would conflict. Does it ever create issues for you if you need to type the backtick in the terminal? I found that Ctrl-A does a great job: it is conveniently located in relation to other keys that I need to interact with after I activate the prefix, and is in general easy to use.
- xiaomai 1y agoI also use backtick for my tmux leader key. It doesn't create issues for me in the terminal (but you need to tap it twice when you want a literal backtick). This became natural for me pretty quickly.
- EPendragon 1y agoGood to know. Thanks for the tip!
- homebrewer 1y agoCtrl+A conflicts with readline's "go to the start of line" (unless you're using vim key bindings in your shell, which I find uncomfortable). I've been using Ctrl+Q, it replaces an almost completely useless key combo (flow control if I'm not mistaken), and is easy to press.
- dur-randir 1y agoJust use double Ctrl+A to pass it down: bind C-a send-prefix
- aaronbaugher 1y agoI use F2. Doesn't sound convenient, but it's just the right distance that when I reach out my middle finger hits it accurately.
- alfiedotwtf 1y agoWhen I was a Vim user, tmux was always the first thing I ran when connecting to a machine… But the after moving to Emacs and using Tramp for remote sessions, followed by VS Code with its built-in session management, I never feel the need to even leave the editor let along manage sessions
- jnpnj 1y agoI just found out about https://stackoverflow.com/a/52838493 https://stackoverflow.com/a/52838493 Host myhost Hostname host User user RequestTTY yes RemoteCommand tmux new -A -s foobar
- homebrewer 1y agoThis breaks rsync & many other things that rely on SSH as transport. Try: alias ssh="ssh -o RequestTTY=force -o RemoteCommand='tmux new -A -s foobar'"
- idatum 1y agoOr just use a different myhost, like "t-myhost" (i.e. myhost != hostname)?
- homebrewer 1y agoWhich would require creating a couple of hundred (in my case) duplicate host aliases instead of adding one shell alias that can be used with any host, including those not mentioned in ~/.ssh/config.
- godelski 1y agoYou can resolve this with a conditional. See the `Match` keyword. Though I agree, probably not the best solution to start all sessions with tmux. There's other issues it can cause.
- 1y ago
- aboardRat4 1y ago>I felt overwhelmed by the very poor default UI that it offers and the amount of options and shortcuts that I needed to know to operate it well and be productive Typical Macintosh user.
- EPendragon 1y agolol, that's likely part of the problem :D I have started using nvim about a year ago, and that one also took three separate tries before it finally stuck with me :) After that, about 8 months ago I found tmux and had a harsh "first impression". These days I enjoy using both of those tools and get more excited the more I learn about them.
- burnt-resistor 1y agoLazyVim helped save me time configuring nvim for a broad range of integrations. It's modular and customizable.
- EPendragon 1y agoI tried LazyVim a couple of times, but felt that I would rather go back to a simpler nvim setup, and then build it up myself and learn as I go. I have stuck and enjoyed kickstart.nvim: https://github.com/nvim-lua/kickstart.nvim https://github.com/nvim-lua/kickstart.nvim It has been my starting point, and I have gradually been adding new plugins and reconfiguring existing ones.
- EPendragon 1y ago@HNModerators, I don't know why it was necessary to change the title of my post from "Customizing tmux and making it less dreadful" to "Customizing tmux". The point of the title was not the overview of all of the customization options, but the effort to make it more usable, convenient, and pleasant to use.
- accrual 1y agoIt may have happened automatically at submission time. Otherwise, my best guess is that it appeared like an editorialized title. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- EPendragon 1y agoI have noticed that about an hour ago, so I don't think it was automatic. I guess I'm just curious why it was found to be against the guidelines or not representative of the topic in the post.
- em-bee 1y agohow is it editorialized? it matches the title of the article. removing part of that title is editorializing.
- akkartik 1y ago"When I first started using tmux, I felt overwhelmed by the very poor default UI that it offers and the amount of options and shortcuts that I needed to know to operate it well and be productive. It took me several tries before I started to feel more or less comfortable with it. One of the things that stood out to me right away was how dreadful UI looked. Not only it felt uninviting, but it almost felt “gatekeepy” - if you don’t know how to use it in this configuration, then might as well forget about it." EPendragon elaborate on this. It seems like you understand the shell enough to use it productively and customize it to be how you like it. The screenshot this quote is talking about looks like a shell? In what way is it dreadful, and in what way do your customizations make it not dreadful? For example, it seems like a valid criticism that shells are not very discoverable and a prompt and blinking cursor can be intimidating to a noob, and that surely applies to tmux as well. But then changing the shortcuts doesn't really address that, does it? To me it seems your article is either saying, "tmux is a pig, and here's me putting some lipstick on it," :) or the problems are not insurmountable, and the solutions are nice but not life-changing. It's great that you like it better now, and we're all having fun chatting around it about how we configure our tools here on the Hacker News :) But I don't see why it's "dreadful". It's just.. computers, no? Tmux seems no more gatekeepy than any other aspect of computers. And I say this as someone who stopped using tmux a few years ago after getting super annoyed with it.
- EPendragon 1y agoHey, akkartik! The initial experience where I saw a lot of elements on the screen without knowing what's what was a lot. And sure enough - a lot of it had to do with just learning how it works and what's what. But in addition to the UI that is unintuitive for the beginner, most of the keybindings either didn't make sense or were not convenient (talking about prefix). For example, splitting panes in my opinion are much better done with | and - symbols rather than " and %. I can see what they were going for with double quotes and the percent sign, but IMO vertical line and a hyphen make more sense. I do not need to be actively thinking about which one should I use for a vertical vs horizontal split. There was some aspect of "putting a lipstick on it" - for sure. Making it more pleasant to look at didn't improve function - just looks. I just think making your tools look the way you like and enjoy them will create a more pleasant experience and help you learn the tool faster too. The dreadfulness did come from not understanding it completely and being a noob early on. Fixing the style and function also put me into a process of being intentional about learning how the tool works and adjusting things that I didn't like. And you're right - it is not more gatekeepy that other tools per se. I was simply describing my experience and what I ended doing about that.
- lemonwaterlime 1y agoThe best way I have found to use tmux is to unbind everything and set only the things I use for my workflow. Then the configuration (.tmux.conf) becomes the docs. I was inspired by the "How to Configure tmux from scratch" post [1]. I came up with my use cases: - I want to create sessions - I want to open and close windows - I want to create split panes - I want to use vim-style text select - etc. Then I made mappings for the things I care about for my workflow specifically. Before this, I would accidentally hit a keybinding while doing something else and not know how I got to that state, taking me out of flow to troubleshoot. Afterwards, only the keybindings I have defined take action. Now tmux fits like a glove. Because tmux is so stable, I haven't had to touch my config in years. It's worth the one time effort. [1] https://ianthehenry.com/posts/how-to-configure-tmux/ https://ianthehenry.com/posts/how-to-configure-tmux/
- skydhash 1y agoI haven't strayed from tmux default configuration that much over the years (and these days, I don't even bother to alter it). The reason is that it's just another set of keybinding shortcuts to memorize, and if I forget some, the help screen is clone. But the few that are ingrained are guaranted to work everywhere.
- phatskat 1y ago> Before this, I would accidentally hit a keybinding while doing something else and not know how I got to that state, taking me out of flow to troubleshoot. I used to accidentally background my tmux frequently and the first couple times made my heart sink in that “did I save??” way lol, though these days I’ve largely stoped using it since splits feel smoother in Kitty and I don’t do any remote sessions.
- deleted 1y ago[deleted]
- phatskat 1y agoIdk why I said kitty but I’m using ghostty
- burnt-resistor 1y agoI was sad to discover that not all string-like config items accept input from external processes. I had to resort to on-the-fly sed templating as a hackaround. Glad that that it supports XDG though.
- Jedd 1y agoI tend to use byobu as a wrapper around tmux wherever possible - this combination might have gotten the author close enough to where they wanted to be. Well, they'd still need to bring their own ascii teacup. https://www.byobu.org/ https://www.byobu.org/
- gertlex 1y agoI also am a fan, and find it much easier to successfully suggest byobu to others with its simple "F-key to action" mapping of common actions. I work with a bunch of non-developers, so the lower barrier to use is important :)
- EPendragon 1y agoI will check this out. Thanks for the link!
- linsomniac 1y agoI've largely given up using tmux in favor of wezterm: wezterm has the ability to remote connect to a persistent terminal running on another machine, and has native window objects so things like mouse support and copy/paste work out of the box. It also has a kind of mosh-like support, though not quite as good at persisting connections over bad networks or network disconnections as mosh+tmux. The down side is that it's really sensitive to versions, right now I'm struggling to get it to work on NixOS in the version that I have running on my Ubuntu dev box and MacOS laptop.
- glaucon 1y ago"One of the things that stood out to me right away was how dreadful UI looked. Not only it felt uninviting, but it almost felt “gatekeepy” - if you don’t know how to use it in this configuration, then might as well forget about it." I'm puzzled how we get from unintuitive interface to "gatekeepy" (which I'm assuming implies a deliberate attempt to make the set of users small). Things can be difficult to use without anyone setting out to exclude new users, some things _are_ difficult to use, and other things are written by people who haven't been paid to make them address the needs of a wider range of users than they want to.
- EPendragon 1y agoglaucon, I agree with you. Most of feeling of "gatekeepiness" came from being a novice at using tmux and having to get used to a new workflow. tmux is as gatekeepy as vim, or other complex cli tool is - if you have never used it in the past, you might find it to be a challenge. That was all I was trying to point out. It is an entry in a diary of a noob tmux user :D
- AceJohnny2 1y agouse iTerm2. (if you're on a Mac) It's free https://iterm2.com/ https://iterm2.com/ As someone who lives in terminals, iTerm2 may be the Killer App for Macbooks. You see, it has Tmux Integration [1], which makes tmux windows and panes become native tabs and panes in iTerm, which means I don't need to use weird chords to manipulate tmux, but most importantly, most UX-ily, it has native scrollback. No need to escape into a weird secondary mode just to do the most basic thing that all graphical terminals are good for. If you work with terminals on remote machines, you owe yourself to use tmux. If your client is a Mac(book), you owe yourself to use iTerm2. The weird thing is that iTerm2 is the only Terminal Emulator to leverage Tmux's Control Channel mode, for the integration. For all the breadth of copycat terminal emulators on Linux, none of them perform this one killer feature. [1] https://iterm2.com/documentation-tmux-integration.html https://iterm2.com/documentation-tmux-integration.html
- ascorbic 1y agoHave you used iTerm's built-in tmux integration? It's a while since I used it because I don't do development on a remote machine anymore, but I liked the way it mapped tmux tabs and panes to native iTerm ones
- EPendragon 1y agoI will need to try iTerm's tools to see if I can do all of the same flow. Is it scriptable and does it have the same persistence features?
- hnarn 1y agoI only customized tmux once, and that was just for fun to change the colors at a previous job to match the branding on some of our servers. Other than that, I always use the default CTRL+B (MOD) and rarely if ever do anything other than the following: - MOD + d to detach, "tmux a" to attach - MOD + c to create new window - MOD + % to create new split pane, " for horizontal - MOD + space to change between pane layouts - MOD + pgup to scroll in buffer
- mrweasel 1y agoI have to admit I don't like customizing tools like tmux too much. Personally I prefer to just learn and live with the defaults. That mean losing out on some things, but I think it's a good trade off for having thing just work like you expect on random server you sign in to. Especially something like keyboard shortcuts and leader keys doesn't make sense to change in my mind. It just confuses you when login in to a remote host.
- EPendragon 1y agoI have thought about that. For this same reason I did not remap a lot of keys in nvim, because I still want to be able to use vim wherever I work if that is the only option. However, I think that creating a simple git repository with rc files and configuration can be used to create a uniform experience across machines.
- mrweasel 1y agoThe git repo idea is fine for some machines, but when I log into a random customers server at 4:00AM to fix some issue that paged me, I'm not spending time cloning a repo to setup neither vim nor tmux, it just has to work. Also the machine may not actually able to reach out onto the wider internet.
- EPendragon 1y agoI think it depends on the use case. If I had to do what you do with random machines, I would probably need to be familiar with default tool setups as well
- phatskat 1y agoAnd for me, the most SSH’ing I do these days is into my docker containers and odds are I won’t be opening vim while I’m there. I do like the repo idea, but I wonder if there’s an easier and maybe faster way to do it over the SSH tunnel
- Jenk 1y ago
- d4rkp4ttern 1y agoSpeaking of prefix-key binding -- I find all control-key combos painful. I use the UHK split keyboard, and set mod-space as the prefix key which is very ergonomic.
- d4rkp4ttern 1y agoI recently dove into Tmux just to be able to combine it with Claude-Code(CC): allowing CC to watch and interact with a CLI application in a separate pane. A nice feature of tmux is that it is scriptable, I.e allows programmatically sending keystrokes to a specific pane. So I built this little tool "tmux-cli" that creates a convenient, safe wrapper (that prevents self-killing, and has built-in delays for Enter key, etc) around tmux that lets CC spawn another pane, launch a CLI script and actually interact with it. This gives CC some interesting abilities: interact with CLI scripts expecting user input; spawn another instance of CC and give it a task (like sub-agents but fully-visible); launch a CLI script with a debugger like Pdb and stepping thru it; launch UI servers and use Puppeteer MCP to check the browser. It's easy to install via uv: uv tool install claude-code-tools https://github.com/pchalasani/claude-code-tools https://github.com/pchalasani/claude-code-tools
- EPendragon 1y agoThat's an awesome tool you made! For me scriptability of tmux is one of its selling points. You have taken it a step further. Love to see it!
- christophilus 1y agoI use a window manager and have never bothered with tmux, except as a screen alternative to keep processes alive on servers every once in a while. I don’t like the idea of learning a 3rd set of key bindings in order to get what my window manager mostly gives me. For those of you who use a tiling or scrolling window manager and tmux, what’s your selling point?
- donkeybeer 1y agoSSH
- christophilus 1y agoYeah. I use it for that, but that's a pretty rare case for me. I'd like to hear from folks who use it as their dev environment in addition to a good window manager. In that scenario, it seems largely superfluous, though session resumption is nice.
- timonoko 1y agoTmux is reborn, because there is only one terminal window available on Termux. But only customization so far is metahar = C-b, because C-a needed on Emacs.
- NoGravitas 1y agoC-b is used by Emacs, though, and I'd hate to lose that family of keys. I use C-z, which is bound by default in Emacs, but also largely useless.
- timonoko 1y agoWhat? C-z was most important, when you had only 300 bit/s shell-account.
- masfoobar 1y agoAs an emacs user, I struggle to see the purpose of tmux when emacs gives me a lot of control of my screen layout. I can see its purpose for vim users... maybe tmux can still have some features for neovim users. For emacs.. my answer is simply all-in emacs. When I saw a screenshot of emacs in the article, I thought I was in for some education... but sadly not the case. Maybe I am missing the point - but I am happy to learn.