7 ms·
The Power of Tmux Hooks
- hnzix 9y agotmux has geek appeal and I can see the use case for remote sessions, but for local macos dev I've changed to just use iTerm for splits (I tried byobu as well). tmux seems to need extra yak shaving to get vim integration, copy/paste and scrollback configured nicely and I just couldn't see the benefit over iTerm's native functionality. Can anyone sell me on tmux over iTerm for local dev?
- stefco_ 9y agoI don't think it's very useful for local dev, but it is a lifesaver for SSH work on spotty connections (or any other case where you might want to leave a workspace intact despite losing connection). But if you're already using iTerm, you should just use its built in tmux integration, which lets you keep using iTerm splits and windows while iTerm handles the tmux stuff. You can do this by launching tmux with the -CC option: tmux -CC attach || tmux -CC This is one of my favorite things about iTerm! Combine that with custom profiles for each server and automatic profile switching (and a few other gems), and working remotely is scarcely harder than working locally! The vim stuff is not too hard to get around IIRC. I don't remember the details, but you can have a look at my .vimrc [0] if you want an example that works on remote servers through tmux with iterm. [0] https://github.com/stefco/dotfiles/blob/master/linkfiles/.vimrc https://github.com/stefco/dotfiles/blob/master/linkfiles/.vi...
- ephimetheus 9y agoI used to do that, but eventually switched to just raw tmux. If you add automatic tmux session saving (via plugin) this becomes a lot more convenient. Also allows me to have one iTerm tab for each server and display the tmux session from that server. Nested tmuxes do not work very well, even if the outer one is managed by iTerm.
- joshka 9y agoI was in the same boat as you until I realized that I usually run a tmux session for longer than the period between iTerm updates. tmux -CC + bury tmux session setting is awesome.
- silves89 9y agoI develop using Linux but sometimes I have to use macOS. Mostly I work locally but sometimes I work on remote boxes. tmux means I get a consistent experience where ever I am. I'm not fully versed in what iTerm can do but tmux does splits and tabs. The tabs are very useful. I can also use tmuxinator so I can start up with a standard set of splits and tabs very quickly. There are the issues you mentioned. But once it's configured I don't find those troubling. And once you change the prefix to something sane it's really nice to use. I enjoy moving around tmux. So for me there are big benefits and tmux is one of the first things I install on a new machine.
- laurent123456 9y agoI use the same config in Windows, macOS and Linux so I just need to learn once the shortcuts and it works the same everywhere. I also use it along tmuxinator, which is very convenient to setup sessions. I just need to type "tmuxinator my-project" and it opens the tabs and layouts in the right directories for this project, with "tail -f" running in some panes, mysql client in others, an SSH connection in yet another. Tmuxinator makes configuring all this very straightforward. Scrollback was a bit annoying at first but I got used to it and it's no longer an issue. Copy and paste can indeed still be an issue especially when sshing to a server.
- adrianN 9y agoCan you script iTerm? I usually set up tmux scripts that start a workspace for a project. Splits are set up, a compilation run is started, vim is started with the right files for the project, things like that. Then I can just my_project/start_work.sh and everything is set up the way I like it.
- cormacrelf 9y agoAlacritty. Butter-smooth scrolling as you hold down j in vim. Doesn't have its own scrollback, so use tmux just for that. There is so much less TUI lag, it's on par with using a regular GUI text editor. https://github.com/jwilm/alacritty https://github.com/jwilm/alacritty
- hnzix 9y agoInteresting. Could you use the mouse to interact with scrollback using your workflow? I mostly use keyboard but sometimes I just want to flick upwards and copy a block of scrollback text using the mouse.
- cormacrelf 9y agoYes, through tmux config. https://gist.github.com/sijad/771426b3995eb05faeb6d78926645e56#file-tmux-conf-L72 https://gist.github.com/sijad/771426b3995eb05faeb6d78926645e... Found in https://github.com/jwilm/alacritty/issues/146 https://github.com/jwilm/alacritty/issues/146 Alacritty might get mouse modifiers to use its own text selection (better for a remote session), but that's good enough for me. I use, for extra vim niceness: setw -g mode-keys vi bind-key -T copy-mode-vi 'v' send -X begin-selection bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
- solipsism 9y agoGreat, a complex way to do what should just happen automatically (adjusting to changed resolution or resized terminals). As a long time vim/tmux user, I'm just done with these powerful tools that I have to spend all my time configuring to make useful (nevermind seamless or delightful). It's masochistic. I have way better, meatier, more meaningful things to work on than my dot files.
- gcb0 9y agostill more lackluster hype for tmux that falls sort of making me bother to even install it. I work on ton of remote machines, and it usually goes like tmux command not found screen
- chatmasta 9y agoIf you’re manually SSHing into machines to manage them, surely you could include an “apt install tmux” in there.
- stormking 9y agoOutside of a pure development environment, you can't just install software on a machine. You have to create a change request and have it approved. And the latter just won't happen for stuff like tmux, there's simply no business justification for it.
- lolive 9y agoSame problem here with htop or atop. That sux!
- chatmasta 9y agoMy point was, it seems odd for a company to have a rule like that but also encourage manually SSHing into servers. That manual administration is already a code smell, in that it’s an I mplicit rejection of immutable infrastructure. So it’s funny that the same company would forego immutable infrastructure while disallowing any installation of packages on the server. Either go all the way or not.
- vr46 9y agoEvents and hooks are neat, but I can’t think of a single use case, anyone have suggestions? The idea in the article semis redundant.
- z1mm32m4n 9y agoI keep my build output on watch in a tab and have touched tell macOS to send me a notification when it notices a certain text pattern. It’s especially nice for things like Jekyll rebuilds.
- cormacrelf 9y agoEh, you don't need tmux hooks for that. Just mkfifo notify.pipe grep 'error' < notify.pipe | notify-macosx-or-whatever >/dev/null & compile-whatever | tee notify.pipe Edit: You can do this WAY more simply with bash >() pipes. compile | tee >(grep 'error' | notify >/dev/null)
- diggan 9y agoSure, you dont NEED it, but then you don't need a lot of stuff. I guess the value comes from not having to remember all those commands, just enter the hooks in the config and you have those steps happening automatically for you.
- cormacrelf 9y agoThat's kinda what saving as build.sh is for. IMO tmux is much cooler when you do stuff like running commands in or sending text to a different window. Check out entr(1) for some sweet use cases that are much more fun than the hooks. That vimdiff thing ... I used it a few months ago when trying to replicate some complicated rollup.js compiler output options. Awesome, even though I own Kaleidoscope. http://entrproject.org/ http://entrproject.org/
- kaushalmodi 9y ago> notification .. Jekyll rebuilds I chuckled, I use Hugo :) By the time I save my post and glance towards the browser in other monitor, rebuilding has already finished, and the browser live reload has already displayed the updated post.
- deleted 9y ago[deleted]
- j_s 9y agoAny tmux fans might learn something from the most recent "minimalist guide" discussion, it seemed a bit more in-depth (or perhaps more tips) than others. https://news.ycombinator.com/item?id=15776995 https://news.ycombinator.com/item?id=15776995 https://hn.algolia.com/?query=tmux https://hn.algolia.com/?query=tmux