Two handy shell scripts for managing tmux sessions more efficiently.
- Download both scripts:
# Using wget
wget https://gist.github.com/YOUR_GIST_ID/raw/trun
wget https://gist.github.com/YOUR_GIST_ID/raw/tam
# Or using curl
curl -O https://gist.github.com/YOUR_GIST_ID/raw/trun
curl -O https://gist.github.com/YOUR_GIST_ID/raw/tam- Make them executable:
chmod +x trun tam- Move to a directory in your PATH:
# Option 1: User's local bin (create if doesn't exist)
mkdir -p ~/.local/bin
mv trun tam ~/.local/bin/
# Option 2: System-wide (requires sudo)
sudo mv trun tam /usr/local/bin/- Ensure ~/.local/bin is in your PATH (add to ~/.bashrc or ~/.zshrc):
export PATH="$HOME/.local/bin:$PATH"tmux- Terminal multiplexerfzf- Fuzzy finder (required fortam)
Install dependencies:
# Ubuntu/Debian
sudo apt install tmux fzf
# macOS
brew install tmux fzf
# Arch Linux
sudo pacman -S tmux fzfCreates auto-numbered tmux sessions with optional command execution.
# Create a new session in current directory
trun
# Run a command in a new session
trun npm run dev
# Specify a custom name suffix
trun --name dev npm run dev
# Use a different working directory
trun --path ~/projects/myapp npm start
# Combine options
trun --path ~/projects --name build makeSessions are named based on the directory (e.g., myproject-1, myproject-2).
Interactive session manager with preview and keyboard shortcuts.
# Launch the interactive manager
tamKeyboard shortcuts:
Enter- Attach to selected sessionCtrl-n- Create new sessionCtrl-d- Kill selected sessionCtrl-c- Cancel/exit
Features:
- Shows all sessions with attachment status
- Preview pane shows session content
- Most recent session marked with ★
- Stays open after detaching for quick switching
trunis great for starting development servers in the backgroundtammakes it easy to switch between multiple sessions quickly
Feel free to use and modify these scripts as needed!