
The Power of Tmux Hooks - git-pull
https://devel.tech/tips/n/tMuXz2lj/the-power-of-tmux-hooks/
======
solipsism
Great, 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.

~~~
saulrh
My tmux _does_ resize automatically...? Is there some other kind of resizing
that's necessary? I split side-by-side, I make another terminal emulator tiled
side-by-side, original term narrows to take half the display, tmux's panes
resize so they're still using half the vertical space. I'm really not sure at
all what the point of this post was supposed to be.

~~~
git-pull
Thank you for spotting that.

As of tmux 2.6:

main-horizontal and main-vertical layouts have a main-pane-height/width that
has to be adjusted.

tiled, even-vertical, even-horizontal should automatically resize.

I updated both tmux articles to mention that.

------
j_s
Any 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)

------
hnzix
tmux 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?

~~~
cormacrelf
Alacritty.

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
Interesting. 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
Yes, through tmux config.

[https://gist.github.com/sijad/771426b3995eb05faeb6d78926645e...](https://gist.github.com/sijad/771426b3995eb05faeb6d78926645e56#file-
tmux-conf-L72)

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"

------
vr46
Events 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
I 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
Eh, 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
Sure, 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
That'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/)

