Live data from Hacker News

Getting Started with Tmux

ittavern.com

91–100 of 160 posts

Re: Getting Started with Tmux

#91
post #44

Among many tricks and tips, I recommend mapping `|` and `-` to split panes: bind-key | split-window -h bind-key - split-window -v More on my wiki: https://wiki.rsapkf.org/notes/unix/tmux/

I've bound the keys 'v' and 's' for vertical and horizontal splitting to match Vim's default bindings.

What tmux calls horizontal and vertical splits is inverse of those in Vim - hence -h flag for what most would call as vertical split. I suspect one of the authors was Australian!

Re: Getting Started with Tmux

#92
For Windows users: Install Windows Terminal and enable WSL. WSL or WSL2 are both fine (I use both). I have like 10 tmux sessions going in 2 or 3 tabs. It's a whole new level of CLI on a Windows box. Loving it.

Re: Getting Started with Tmux

#93

As a heavy GNU Screen user for the last 2 decades it’s always in the back of my mind if I should be switching to tmux. Maybe there is a compatibility mode. For those who switched from screen what was the biggest benefit?

For me, it was tmux mouse mode, The window names in the status bar become clickable.

Re: Getting Started with Tmux

#94
I use URxvt and a systemd-run to daemonize tmux even if I close my graphical session.

I use a function for the local tmux session and an alias for remote ssh tmux sessions, with a different bindings (MOD+x & MOD+w).

Like that I am always in tmux localy and remotely just by launching URxvt.

    # open a new tmux session named ssh_tmux or attach to it
    alias tmuxs='tmux new-session -A -s ssh_tmux && exit'
    # open a new default tmux session with a named default or attach if it exist
    tmuxa () {
        systemd-run -q --scope --user tmux new-session -A -s default "$@"
        exit
    }

    # run tmux if TMUX variable is null
    if [[ "${TERM-}" != tmux* ]] && [[ -z "${TMUX}" ]] && [[ -z "${SSH_CONNECTION}" ]]; then
        tmuxa
    elif [[ -z "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]]; then
        tmuxs
    fi

Re: Getting Started with Tmux

#95

My favorite antipattern is, you can just leave a script that does an event loop running in the foreground, detatch tmux, and voila, you have a 'server'. Works great in a pinch or when you just don't need to finish it.

Also been doing this for years. And always wondered about possible disadvantages, or is there any reason why it is not used like this by everyone?

Main disadvantages: restart services if they crash (so run them in a loop); security and isolation of services from each other and the OS; restart services on reboot. I've solved these problems: https://tobykurien.com/simpler-linux-selfhosting/

Re: Getting Started with Tmux

#97
post #44

Among many tricks and tips, I recommend mapping `|` and `-` to split panes: bind-key | split-window -h bind-key - split-window -v More on my wiki: https://wiki.rsapkf.org/notes/unix/tmux/

As an alternative for vertical splitting, using _ (instead of -) means both types of splitting require a `shift` which keeps it a little more symmetrical if that's how your brain works!

Depends on your keyboard layout. On my (Finnish) keyboard, | requires alt.

Re: Getting Started with Tmux

#98

The best way to use tmux is with -CC, which iTerm maps to native UI. tmux tabs and panes become native tabs and panes and your session is immortal, and it’s a far better experience than mosh or whatever the latest thing in this area is. I have never bothered to figure out how the keybindings actually work and I probably never will, but I enjoy using it all the time because of this.

does all of this work with the tmux keyboard shortcuts? the main reason I use tmux is to avoid the mouse...

You use iTerm shortcuts instead. You can customize those as you like. So it feels just like using iTerm, but the panes are running in tmux.

The main reason to do this (for me) is to use (tmuxp)[https://tmuxp.git-pull.com] to configure window sets for different projects / clients and start them up quickly.

Re: Getting Started with Tmux

#99
post #97

Earlier quoted context omitted.

As an alternative for vertical splitting, using _ (instead of -) means both types of splitting require a `shift` which keeps it a little more symmetrical if that's how your brain works!

Depends on your keyboard layout. On my (Finnish) keyboard, | requires alt.

Ah right, fair enough!
Post reply on HN