If you use tmux regularly, you've probably noticed that some common operations require typing out relatively long commands or remembering specific flags. After years of daily tmux usage, I've developed a set of shell functions and aliases that make working with tmux sessions more pleasant and efficient.
These functions provide intuitive shortcuts for common tmux operations, with some added smarts to handle edge cases. Here's what they do:
The tm
function is a simple launcher that either starts a new tmux session if
none exist, or brings up a session picker if you have multiple sessions running.
This saves you from having to check session status manually before deciding what
command to run.
For session management, there's tm-create
for creating new sessions (with
automatic detachment from current session if needed), tm-attach
for attaching
to sessions, and tm-rename
for renaming them.
The functions also include other quality-of-life improvements like tm-title
for setting pane titles, and aliases for common operations like reloading the
tmux config (tm-source
) or editing it (tm-edit
).
Below is the complete set of functions and aliases that you can add to your shell configuration. Hope you find it useful!