Live data from Hacker News

Tmux for Mere Mortals

zserge.com

121–130 of 171 posts

Re: Tmux for Mere Mortals

#121

If you use vim as your IDE and haven't already, make use of nerdtree with its git addon[1] along with tmux. I use different tmux colors for different environments so I know where I'm at instantly. [1] https://medium.com/@victormours/a-better-nerdtree-setup-3d39...

How are you setting your tmux colours in different environments?

I have this in my ~/.bashrc:

    declare -A TMUX_SSH_COLORS_TABLE                                                                                                
    TMUX_SSH_COLORS_TABLE=( \                                                                                                       
        ["server"]="fg=yellow bold,bg=black" \
        ["router"]="fg=red bold,bg=black" \                                                                                                                                                                                      
        ["desktop"]="fg=white bold,bg=black" \                                                                                      
    )                                                                                                                               
                                                                                                                                                                                                                                                                      
    function ssh {                                                                                                                  
        trap 'tmux select-pane -t:. -P "default"' RETURN                                                                            
        for arg; do                                                                                                                 
            local arg_value="${TMUX_SSH_COLORS_TABLE[$arg]}"                                                                        
            [[ -n "${arg_value}" ]] && tmux select-pane -t:. -P "${arg_value}"                                                      
            break                                                                                                                   
        done                                                                                                                        
        /usr/bin/ssh "$@"                                                                                                           
    }
On my laptop, `ssh desktop` will switch my tmux colors and then when ssh dies/quits/etc I go back to the default color scheme.

Re: Tmux for Mere Mortals

#122

Earlier quoted context omitted.

> I could understand if you don't like tmux for other reasons I love tmux and I'm primarily a keyboard user. But sometimes I like to copy a short string from one window to another. Does tmux-yank allow you to middle-click paste on a tmux window? does it allow to select to copy?

Middle-click paste is an option offered by the terminal application. It has nothing to do with tmux

Yet tmux "captures" the middle click and decides to do nothing with it (instead of pasting the text, as correctly happens within vim).

Re: Tmux for Mere Mortals

#123

I have honestly never seen any big value in using tmux over screen. I do all the multiplexing in my window manager and I use tilix which allows me to sync commands over multiple sessions.

I used screen for like 10-15 years. Two years ago, I switched to tmux because of some rough edges with screen. I can't remember what they were now, I think something to do with selecting the correct terminal type (TERM=screen? TERM=xterm-256color? TERM=screen.xterm-256color?). Something went wrong, and I couldn't fix it.

Normally, I try to keep to the application's defaults for portability, but the screen key-bindings are in my muscle memory. I was able to migrate to tmux almost seamlessly with just a few key-bindings in .tmux.conf, which is reproduced below in its entirety:

(Edit: formatting)

----

# Remap prefix from 'C-b' to 'C-a' (compat screen(1))

unbind C-b

set-option -g prefix C-a

# Send C-a: 'C-a a'

bind a send-prefix

# Flip to previous window: `C-a C-a' (compat screen(1))

bind C-a last-window

# Make C-n and C-p act like 'n' and 'p' (compat screen(1))

bind C-n next-window

bind C-p previous-window

# Make C-a C-[ act like C-a [ (compat screen(1)

bind C-[ copy-mode

# Change background color of status line from green to yellow for readability

set-option -g status-style bg=yellow

# Increase scrollback to 5000 lines from 2000 default

set-option -g history-limit 5000

----

Re: Tmux for Mere Mortals

#124
post #88
post #10

Spent too much time wonking a tmux config only realizing it was never going to work how I liked. You can't have it all with the mouse no matter your settings, there will always be a compromise. It also doesn't help that no one cites the version of tmux they wrote their configs for, nor that the configs are not backwards compatible with all versions of tmux for all settings. It's really clunky, but I went from tmux to…

Tmux on my local machine was useless. Tmux on my server has been a godsent. Just connect and re-attach to the tmux session and you are right where you left off. I did modify the key binds a little bit to make splitting windows and enable the mouse, but otherwise I just don’t need any more advanced behavior.

"Tmux on my server has been a godsent." Exactly. I let my cloud VM tmux sessions run for months. I manage other VMs and Docker containers from my tmux "command center".

Re: Tmux for Mere Mortals

#125

If you use vim as your IDE and haven't already, make use of nerdtree with its git addon[1] along with tmux. I use different tmux colors for different environments so I know where I'm at instantly. [1] https://medium.com/@victormours/a-better-nerdtree-setup-3d39...

Different colors are great even without Tmux. Even in my simple WSL environment I have aliases to open, say,

    alias liveTerm='urxvt -bg "#5b0000" -fb white &'
-so my production ssh will be red, staging green, another site purple, etc.

Re: Tmux for Mere Mortals

#126
post #34

So I predominantly use Macs. The one and only reason why I personally use tmux is because of tmux -CC. I never bothered with screen/tmux simply because I didn't want to learn another whole new set of keybinds (let alone reconfigure them). tmux -CC largely behaves as a native app. Want a new tab? CMD+T. New window? CMD+N. Scrollback with the trackpad. That sort of thing. The complete system is iterm2 + tmux -CC + et (…

How is the behavior in et compared to setting up a no kill signal from your ssh config? Sometimes my no kill signals get killed after a half hour or longer.

Won't that still run afoul of losing your network connection? et is resilient to those sorts of changes. Anything short of a reboot, really.

Re: Tmux for Mere Mortals

#127
post #79
post #10

Spent too much time wonking a tmux config only realizing it was never going to work how I liked. You can't have it all with the mouse no matter your settings, there will always be a compromise. It also doesn't help that no one cites the version of tmux they wrote their configs for, nor that the configs are not backwards compatible with all versions of tmux for all settings. It's really clunky, but I went from tmux to…

> You can't have it all with the mouse no matter your settings I don't think this is correct; it's just that it's not trivial to get things working well. As you say, it depends on using an up-to-date version of tmux (and sadly, you often can't run a config made for a new version with an older version of tmux). And you'll need your terminal to be up to the task (eg. iTerm2 on macOS; not sure what the best thing on Lin…

> not sure what the best thing on Linux would be

Recently I have been a big fan of tmux+Alacritty on linux.

Re: Tmux for Mere Mortals

#128
Hi there! I'm the author and maintainer of Byobu (byobu.org) here. Byobu started as "Screen for mere mortals", but eventually pivoted to work with Tmux, as well. Nowadays, Byobu is much more tightly tied to Tmux. You can think of it, as a super opinionated set of Tmux settings, easily portable across all of your machines. Happy to answer any questions here!
Post reply on HN