From 0ae72d5ae238066eb0feba650820792c0f84a0c6 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 7 Feb 2026 17:06:37 -0600 Subject: feat(common): add aix script for fzf-based Claude Code tmux launcher Provides flexible alternative to ai-assistants: multi-select project directories via fzf, then open each in a tmux window running Claude. Co-Authored-By: Claude Opus 4.6 --- dotfiles/common/.local/bin/aix | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 dotfiles/common/.local/bin/aix (limited to 'dotfiles/common/.local') diff --git a/dotfiles/common/.local/bin/aix b/dotfiles/common/.local/bin/aix new file mode 100755 index 0000000..0f70d23 --- /dev/null +++ b/dotfiles/common/.local/bin/aix @@ -0,0 +1,74 @@ +#!/bin/bash +# Launch tmux session with Claude in fzf-selected project directories + +SESSION="claude" + +# If session exists, attach or switch to it +if tmux has-session -t "$SESSION" 2>/dev/null; then + if [ -n "$TMUX" ]; then + tmux switch-client -t "$SESSION" + else + tmux attach-session -t "$SESSION" + fi + exit 0 +fi + +# Dependency checks +for cmd in fzf tmux claude; do + if ! command -v "$cmd" &>/dev/null; then + echo "Error: $cmd is not installed" >&2 + exit 1 + fi +done + +# Build candidate directory list +candidates=() +[ -d "$HOME/.emacs.d" ] && candidates+=("~/.emacs.d") +if [ -d "$HOME/code" ]; then + while IFS= read -r d; do + candidates+=("~/${d#"$HOME"/}") + done < <(find "$HOME/code" -maxdepth 1 -mindepth 1 -type d | sort) +fi +if [ -d "$HOME/projects" ]; then + while IFS= read -r d; do + candidates+=("~/${d#"$HOME"/}") + done < <(find "$HOME/projects" -maxdepth 1 -mindepth 1 -type d | sort) +fi + +# Present fzf for multi-select +selections=$(printf '%s\n' "${candidates[@]}" | fzf --multi --height=70% --reverse) +[ -z "$selections" ] && exit 0 + +# Claude command — separated for safe editing +AI_CMD="claude" +AI_INSTRUCTIONS='Read docs/protocols.org and docs/NOTES.org, follow instructions exactly, then begin the session-start workflow' + +# Read selections into array +selected=() +while IFS= read -r line; do + selected+=("$line") +done <<< "$selections" + +# Create session with first selection +first="${selected[0]}" +dir="${first/#\~/$HOME}" +name="$(basename "$dir")" +tmux new-session -d -s "$SESSION" -n "$name" -c "$dir" +tmux send-keys -t "$SESSION:$name" "$AI_CMD \"$AI_INSTRUCTIONS\"" Enter + +# Create remaining windows +for entry in "${selected[@]:1}"; do + dir="${entry/#\~/$HOME}" + name="$(basename "$dir")" + tmux new-window -t "$SESSION" -n "$name" -c "$dir" + tmux send-keys -t "$SESSION:$name" "$AI_CMD \"$AI_INSTRUCTIONS\"" Enter +done + +# Select first window and attach or switch +first_name="$(basename "${selected[0]/#\~/$HOME}")" +tmux select-window -t "$SESSION:$first_name" +if [ -n "$TMUX" ]; then + tmux switch-client -t "$SESSION" +else + tmux attach-session -t "$SESSION" +fi -- cgit v1.2.3