feat(tmux): auto-name sessions with emoji + codename

- scripts/tmux-session-name.sh: generates random emoji + adj-noun name
  40 emojis x 40 adjectives x 40 nouns = 64,000 combinations
  Only renames numerically-named sessions (skips explicit names)

- tmux.conf.local: session-created hook calls the script automatically

- shell/common: added DOTFILES=$HOME/dotfiles env var so hooks and
  scripts can find the dotfiles root without hardcoded paths

Examples: '🐉 sonic-oracle', '🌟 electric-nebula', '🔱 nova-comet'
This commit is contained in:
2026-07-18 14:50:14 +05:30
parent 1ec7aff593
commit 7c54482746
3 changed files with 64 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# tmux-session-name.sh — Auto-name new tmux sessions with emoji + codename
#
# Called by the session-created hook in .tmux.conf.local
# Usage: tmux-session-name.sh <current_session_name> <session_id>
#
# Only renames if the current name is purely numeric (tmux's default
# auto-numbering: 0, 1, 2 …). Explicitly named sessions are left alone.
CURRENT_NAME="${1:-}"
SESSION_ID="${2:-}"
# Skip if name is not a plain number (user explicitly named the session)
if [[ ! "$CURRENT_NAME" =~ ^[0-9]+$ ]]; then
exit 0
fi
# ── Name pool ─────────────────────────────────────────────────────────────────
EMOJIS=(
"⚡" "🔥" "🌙" "🚀" "🎯" "💎" "🌊" "🎸" "🦊" "🐉"
"🌟" "🎭" "🔮" "🦋" "🌸" "🏔️" "🎪" "🦁" "🐺" "🦅"
"🐬" "🌋" "⚗️" "🧠" "🔭" "🎲" "🏹" "🌀" "🦄" "🐙"
"🎮" "🛸" "🌈" "🔱" "⚜️" "🧬" "🦾" "💫" "🎆" "🌌"
)
ADJECTIVES=(
swift blazing cosmic silent wild golden dark frozen epic neon
cyber ghost storm iron crystal hyper zen rogue nova apex
void shadow turbo lunar sonic electric primal ancient savage brave
mystic toxic ultra prime omega alpha delta sigma raging burning
)
NOUNS=(
wolf phoenix raven otter falcon dragon viper lynx shark cobra
titan spectre nexus cipher forge matrix pulse blade hawk panther
manta kraken hydra mantis raptor condor jaguar orca wraith banshee
golem oracle anvil tempest quasar nebula comet prism zenith apex
)
# ── Pick random combination ───────────────────────────────────────────────────
EMOJI="${EMOJIS[$RANDOM % ${#EMOJIS[@]}]}"
ADJ="${ADJECTIVES[$RANDOM % ${#ADJECTIVES[@]}]}"
NOUN="${NOUNS[$RANDOM % ${#NOUNS[@]}]}"
NEW_NAME="${EMOJI} ${ADJ}-${NOUN}"
# ── Rename ────────────────────────────────────────────────────────────────────
if [[ -n "$SESSION_ID" ]]; then
tmux rename-session -t "$SESSION_ID" "$NEW_NAME" 2>/dev/null
else
# Called standalone — just print the name
echo "$NEW_NAME"
fi