#!/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 # Usage: tmux-session-name.sh CURRENT_NAME="${1:-}" SESSION_ID="${2:-}" # Skip if name is empty or not a plain number (user explicitly named it) if [[ -z "$CURRENT_NAME" || ! "$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 ─────────────────────────────────────────────────── # We use absolute arithmetic expansion to avoid negative index quirks EMOJI="${EMOJIS[$((RANDOM % ${#EMOJIS[@]}))]}" ADJ="${ADJECTIVES[$((RANDOM % ${#ADJECTIVES[@]}))]}" NOUN="${NOUNS[$((RANDOM % ${#NOUNS[@]}))]}" NEW_NAME="${EMOJI} ${ADJ}-${NOUN}" # ── Rename ──────────────────────────────────────────────────────────────────── if [[ -n "$SESSION_ID" ]]; then # Use -t with the specific session ID to avoid targeting the wrong session tmux rename-session -t "$SESSION_ID" "$NEW_NAME" 2>/dev/null else # Called standalone — just print the name echo "$NEW_NAME" fi