Skip to main content

Shell Aliases System

Three shell functions provide quick tmux session management from the command line.

Quick Reference

Default CommandShell AliasDescription
tmux attach -t <name> or tmux switch-client -t <name>ta <name>Attach to session (or switch inside tmux)
tmux lstlList all sessions
tmux new-session -d -s <name> + attachtns <name>Create new session and attach

Usage Examples

# List sessions
tl

# Attach to an existing session
ta work

# Create and attach a new session
tns monitoring

Implementation

These functions are defined in ~/.bash_aliases/TMUX/tmux.sh:

ta() {
if [ -z "$1" ]; then echo -e "Usage: ta <session-name>"; return 1; fi
if [ -n "$TMUX" ]; then tmux switch-client -t "$1";
else tmux attach -t "$1"; fi
}
tl() { tmux ls "$@"; }
tns() {
if [ -z "$1" ]; then echo -e "Usage: tns <session-name>"; return 1; fi
tmux new-session -d -s "$1"
if [ -n "$TMUX" ]; then tmux switch-client -t "$1";
else tmux attach -t "$1"; fi
}

Alias Loader Architecture

The functions are loaded automatically by this chain:

~/.bashrc
→ sources ~/.bash_aliases_loader
→ finds all *.sh files under ~/.bash_aliases/*/
→ sources them automatically

The loader script (~/.bash_aliases_loader) is directory-based — any .sh file added to any subdirectory of ~/.bash_aliases/ is loaded automatically without modifying .bashrc.

~/.bash_aliases/
├── TMUX/tmux.sh ← tmux aliases live here
├── APT/ ← system package aliases
├── Listing/ ← ls, eza, tree aliases
├── Search/ ← grep, rg, find aliases
└── ... ← any new directory loads automatically

Adding Your Own Alias

  1. Create a new .sh file in ~/.bash_aliases/<category>/
  2. Define your function or alias
  3. Open a new terminal or run source ~/.bashrc