brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: command-alias gives a tmux command a short name of your own

Tmux
~/tips/tip-tmux-command-alias

set -s command-alias[100] 'rl=source-file ~/.tmux.conf'

Creates your own shortcuts for long tmux commands at the prompt.

Some commands you type at Ctrl-b : are long enough to get wrong. tmux lets you define aliases for them.

set -s command-alias[100] 'rl=source-file ~/.tmux.conf'
set -s command-alias[101] 'zoom=resize-pane -Z'

command-alias is a server option and an array, which is why it needs -s and an index in square brackets. Each entry is name=command. After this, Ctrl-b : and rl reloads the config, and zoom -t:.1 zooms pane 1, because extra arguments are added to the end of the expansion.

tmux ships with a few aliases of its own at low indexes. You can see them with:

tmux show -s command-alias

That is why I’d start them at 100, so they don’t replace a built in one by accident.

Aliases are expanded when the command is parsed. If you use an alias inside a bind, tmux stores the expanded command, and changing the alias later doesn’t change that binding. An alias also only applies when a command name is unknown, so you can’t override a real command like split-window with it.

Further reading: tmux manual page (OpenBSD)

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link