home

Uses

the configs i work in, copy-ready. each one has a curl line.

  • ai agent claude
  • orchestrator grok bot
  • ade t3 code
  • browser cra
  • terminal kitty
  • shell fish, starship, fzf, zoxide
  • multiplexer tmux
  • editor neovim (LazyVim)
  • git lazygit
  • windows rectangle
  • dotfiles chezmoi
  • computer macbook pro, m1 pro, 32gb
  • phone iphone 17
  • headphones jbl 770nc
  • earbuds airpods pro 2

the rest, including nvim and fish, is in my dotfiles. the thinking behind it is in my dev setup is better than yours.

project switcher

one key opens fzf over your project folders. pick one and you get a tmux session at the project root, or you jump to it if it already exists. based on ThePrimeagen's tmux-sessionizer, with my pane cache and session commands.

curl -fsSL https://www.elregaldo.com/uses/tmux-sessionizer --create-dirs -o ~/.local/bin/tmux-sessionizer && chmod +x ~/.local/bin/tmux-sessionizer
tmux-sessionizer (show)
#!/usr/bin/env bash
CONFIG_FILE_NAME="tmux-sessionizer.conf"
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/tmux-sessionizer"
CONFIG_FILE="$CONFIG_DIR/$CONFIG_FILE_NAME"
PANE_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/tmux-sessionizer"
PANE_CACHE_FILE="$PANE_CACHE_DIR/panes.cache"

# config file example
# ------------------------
# # file: ~/.config/tmux-sessionizer/tmux-sessionizer.conf
# # If set this override the default TS_SEARCH_PATHS (~/ ~/personal ~/personal/dev/env/.config)
# TS_SEARCH_PATHS=(~/)
# # If set this add additional search paths to the default TS_SEARCH_PATHS
# # The number prefix is the depth for the Path [OPTIONAL]
# TS_EXTRA_SEARCH_PATHS=(~/ghq:3 ~/Git:3 ~/.config:2)
# # if set this override the TS_MAX_DEPTH (1)
# TS_MAX_DEPTH=2
# This is not meant to override .tmux-sessionizer.  At first i thought this
# would be a good command, but i don't think its ackshually what i want.
#
# Instead, its a list of commands to run on windows who's index is way outside
# of the first 10 windows.  This allows you to create as many windows in your
# session as you would like without having your workflow interrupted by these
# programatic windows
#
# how to use:
# tmux-sessionizer -w 0 will execute the first command in window -t 69.
# TS_SESSION_COMMANDS=(<cmd1> <cmd2>)
#
# TS_LOG=true # will write logs to ~/.local/share/tmux-sessionizer/tmux-sessionizer.logs
# TS_LOG_FILE=<file> # will write logs to <file> Defaults to ~/.local/share/tmux-sessionizer/tmux-sessionizer.logs
# ------------------------

if [[ -f "$CONFIG_FILE" ]]; then
    source "$CONFIG_FILE"
fi

if [[ -f "$CONFIG_FILE_NAME" ]]; then
    source "$CONFIG_FILE_NAME"
fi

if [[ $TS_LOG != "true" ]]; then
    if [[ -z $TS_LOG_FILE ]]; then
        TS_LOG_FILE="$HOME/.local/share/tmux-sessionizer/tmux-sessionizer.logs"
    fi

    mkdir -p "$(dirname "$TS_LOG_FILE")"
fi

log() {
    if [[ -z $TS_LOG ]]; then
        return
    elif [[ $TS_LOG == "echo" ]]; then
        echo "$*"
    elif [[ $TS_LOG == "file" ]]; then
        echo "$*" >> "$TS_LOG_FILE"
    fi
}

session_idx=""
session_cmd=""
user_selected=""
split_type=""
VERSION="0.1.0"

while [[ "$#" -gt 0 ]]; do
    case "$1" in
    -h | --help)
        echo "Usage: tmux-sessionizer [OPTIONS] [SEARCH_PATH]"
        echo "Options:"
        echo "  -h, --help             Display this help message"
        echo "  -s, --session <name>   session command index."
        echo "  --vsplit               Create vertical split (horizontal layout) for session command"
        echo "  --hsplit               Create horizontal split (vertical layout) for session command"
        exit 0
        ;;
    -s | --session)
        session_idx="$2"
        if [[ -z $session_idx ]]; then
            echo "Session index cannot be empty"
            exit 1
        fi

        if [[ -z $TS_SESSION_COMMANDS ]]; then
            echo "TS_SESSION_COMMANDS is not set.  Must have a command set to run when switching to a session"
            exit 1
        fi

        if [[ -z "$session_idx" || "$session_idx" -lt 0 || "$session_idx" -ge "${#TS_SESSION_COMMANDS[@]}" ]]; then
            echo "Error: Invalid index. Please provide an index between 0 and $((${#TS_SESSION_COMMANDS[@]} - 1))."
            exit 1
        fi

        session_cmd="${TS_SESSION_COMMANDS[$session_idx]}"

        shift
        ;;
    --vsplit)
        split_type="vsplit"
        ;;
    --hsplit)
        split_type="hsplit"
        ;;
    -v | --version)
        echo "tmux-sessionizer version $VERSION"
        exit 0
        ;;
    *)
        user_selected="$1"
        ;;
    esac
    shift
done

log "tmux-sessionizer($VERSION): idx=$session_idx cmd=$session_cmd user_selected=$user_selected split_type=$split_type log=$TS_LOG log_file=$TS_LOG_FILE"

# Validate split options are only used with session commands
if [[ -n "$split_type" && -z "$session_idx" ]]; then
    echo "Error: --vsplit and --hsplit can only be used with -s/--session option"
    exit 1
fi

sanity_check() {
    if ! command -v tmux &>/dev/null; then
        echo "tmux is not installed. Please install it first."
        exit 1
    fi

    if ! command -v fzf &>/dev/null; then
        echo "fzf is not installed. Please install it first."
        exit 1
    fi
}

is_tmux_client() {
    local pane_tty current_tty

    [[ -n "${TMUX_PANE:-}" ]] || return 1
    pane_tty="$(tmux display-message -p -t "$TMUX_PANE" '#{pane_tty}' 2>/dev/null)" || return 1
    current_tty="$(tty 2>/dev/null)" || return 1
    [[ "$current_tty" == "$pane_tty" ]]
}

attach_session() {
    env -u TMUX -u TMUX_PANE tmux attach-session -t "$1"
}

switch_to() {
    if is_tmux_client; then
        log "switching to session $1"
        tmux switch-client -t "$1" 2>/dev/null || attach_session "$1"
    else
        log "attaching to session $1"
        attach_session "$1"
    fi
}

has_session() {
    tmux list-sessions | grep -q "^$1:"
}

hydrate() {
    if [[ ! -z $session_cmd ]]; then
        log "skipping hydrate for $1 -- using \"$session_cmd\" instead"
        return
    elif [ -f "$2/.tmux-sessionizer" ]; then
        log "sourcing(local) $2/.tmux-sessionizer"
        tmux send-keys -t "$1" "source $2/.tmux-sessionizer" c-M
    elif [ -f "$HOME/.tmux-sessionizer" ]; then
        log "sourcing(global) $HOME/.tmux-sessionizer"
        tmux send-keys -t "$1" "source $HOME/.tmux-sessionizer" c-M
    fi
}

is_tmux_running() {
    tmux_running=$(pgrep tmux)

    if [[ -z $tmux_running ]]; then
        return 1
    fi
    return 0
}

init_pane_cache() {
    mkdir -p "$PANE_CACHE_DIR"
    touch "$PANE_CACHE_FILE"
}

get_pane_id() {
    local session_idx="$1"
    local split_type="$2"
    init_pane_cache
    grep "^${session_idx}:${split_type}:" "$PANE_CACHE_FILE" | cut -d: -f3
}

set_pane_id() {
    local session_idx="$1"
    local split_type="$2"
    local pane_id="$3"
    init_pane_cache

    # Remove existing entry if it exists
    grep -v "^${session_idx}:${split_type}:" "$PANE_CACHE_FILE" > "${PANE_CACHE_FILE}.tmp" 2>/dev/null || true
    mv "${PANE_CACHE_FILE}.tmp" "$PANE_CACHE_FILE"

    # Add new entry
    echo "${session_idx}:${split_type}:${pane_id}" >> "$PANE_CACHE_FILE"
}

cleanup_dead_panes() {
    init_pane_cache
    local temp_file="${PANE_CACHE_FILE}.tmp"

    while IFS=: read -r idx split pane_id; do
        if tmux list-panes -a -F "#{pane_id}" 2>/dev/null | grep -q "^${pane_id}$"; then
            echo "${idx}:${split}:${pane_id}" >> "$temp_file"
        fi
    done < "$PANE_CACHE_FILE"

    mv "$temp_file" "$PANE_CACHE_FILE" 2>/dev/null || touch "$PANE_CACHE_FILE"
}

sanity_check

# if TS_SEARCH_PATHS is not set use default
[[ -n "$TS_SEARCH_PATHS" ]] || TS_SEARCH_PATHS=(~/ ~/personal ~/personal/dev/env/.config)

# Add any extra search paths to the TS_SEARCH_PATHS array
# e.g : EXTRA_SEARCH_PATHS=("$HOME/extra1:4" "$HOME/extra2")
# note : Path can be suffixed with :number to limit or extend the depth of the search for the Path

if [[ ${#TS_EXTRA_SEARCH_PATHS[@]} -gt 0 ]]; then
    TS_SEARCH_PATHS+=("${TS_EXTRA_SEARCH_PATHS[@]}")
fi

# utility function to find directories
find_dirs() {
    # list TMUX sessions
    if is_tmux_client; then
        current_session=$(tmux display-message -p '#S')
        tmux list-sessions -F "[TMUX] #{session_name}" 2>/dev/null | grep -vFx "[TMUX] $current_session"
    else
        tmux list-sessions -F "[TMUX] #{session_name}" 2>/dev/null
    fi

    # note: TS_SEARCH_PATHS is an array of paths to search for directories
    # if the path ends with :number, it will search for directories with a max depth of number ;)
    # if there is no number, it will search for directories with a max depth defined by TS_MAX_DEPTH or 1 if not set
    for entry in "${TS_SEARCH_PATHS[@]}"; do
        # Check if entry as :number as suffix then adapt the maxdepth parameter
        if [[ "$entry" =~ ^([^:]+):([0-9]+)$ ]]; then
            path="${BASH_REMATCH[1]}"
            depth="${BASH_REMATCH[2]}"
        else
            path="$entry"
        fi

        [[ -d "$path" ]] && find "$path" -mindepth 1 -maxdepth "${depth:-${TS_MAX_DEPTH:-1}}" -path '*/.git' -prune -o -type d -print
    done
}

handle_session_cmd() {
    log "executing session command $session_cmd with index $session_idx split_type=$split_type"
    if ! is_tmux_running; then
        echo "Error: tmux is not running.  Please start tmux first before using session commands."
        exit 1
    fi

    current_session=$(tmux display-message -p '#S')

    if [[ -n "$split_type" ]]; then
        handle_split_session_cmd "$current_session"
    else
        handle_window_session_cmd "$current_session"
    fi
    exit 0
}

handle_window_session_cmd() {
    local current_session="$1"
    start_index=$((69 + $session_idx))
    target="$current_session:$start_index"

    log "target: $target command $session_cmd has-session=$(tmux has-session -t="$target" 2> /dev/null)"
    if tmux has-session -t="$target" 2> /dev/null; then
        switch_to "$target"
    else
        log "executing session command: tmux neww -dt $target $session_cmd"
        tmux neww -dt $target "$session_cmd"
        hydrate "$target" "$selected"
        tmux select-window -t $target
    fi
}

handle_split_session_cmd() {
    local current_session="$1"
    cleanup_dead_panes

    # Check if pane already exists
    local existing_pane_id=$(get_pane_id "$session_idx" "$split_type")

    if [[ -n "$existing_pane_id" ]] && tmux list-panes -a -F "#{pane_id}" 2>/dev/null | grep -q "^${existing_pane_id}$"; then
        log "switching to existing pane $existing_pane_id"
        tmux select-pane -t "$existing_pane_id"
        if [[ -z $TMUX ]]; then
            tmux attach-session -t "$current_session"
        else
            tmux switch-client -t "$current_session"
        fi
    else
        # Create new split
        local split_flag=""
        if [[ "$split_type" == "vsplit" ]]; then
            split_flag="-h"  # horizontal layout (vertical split)
        else
            split_flag="-v"  # vertical layout (horizontal split)
        fi

        log "creating new split: tmux split-window $split_flag -c $(pwd) $session_cmd"
        local new_pane_id=$(tmux split-window $split_flag -c "$(pwd)" -P -F "#{pane_id}" "$session_cmd")

        if [[ -n "$new_pane_id" ]]; then
            set_pane_id "$session_idx" "$split_type" "$new_pane_id"
            log "created pane $new_pane_id for session_idx=$session_idx split_type=$split_type"
        fi
    fi
}

if [[ ! -z $session_cmd ]]; then
    handle_session_cmd
elif [[ ! -z $user_selected ]]; then
    selected="$user_selected"
else
    selected=$(find_dirs | fzf \
        --prompt="  session > " \
        --preview 'echo {} | grep -q "^\[TMUX\]" && tmux list-windows -t "$(echo {} | sed "s/\[TMUX\] //")" 2>/dev/null || eza -1 --icons --color=always --group-directories-first {} 2>/dev/null || ls {}' \
        --preview-window=right:40%)
fi

if [[ -z $selected ]]; then
    exit 0
fi

if [[ "$selected" =~ ^\[TMUX\]\ (.+)$ ]]; then
    selected="${BASH_REMATCH[1]}"
fi

selected_name=$(basename "$selected" | tr . _)

if ! is_tmux_running; then
    tmux new-session -ds "$selected_name" -n "$selected_name-n" -c "$selected" "nvim"
    tmux new-window -dt "$selected_name:" -n "$selected_name-cd" -c "$selected"
    hydrate "$selected_name" "$selected"
fi

if ! has_session "$selected_name"; then
    tmux new-session -ds "$selected_name" -n "$selected_name-n" -c "$selected" "nvim"
    tmux new-window -dt "$selected_name:" -n "$selected_name-cd" -c "$selected"
    hydrate "$selected_name" "$selected"
fi

switch_to "$selected_name"

where it looks

search roots with a depth after the colon. ~/ghq:3 means three levels deep, which is what go-style repo layouts need. keep depth low so fzf never lists node_modules.

curl -fsSL https://www.elregaldo.com/uses/tmux-sessionizer.conf --create-dirs -o ~/.config/tmux-sessionizer/tmux-sessionizer.conf
tmux-sessionizer.conf (show)
# Search these roots when tmux-sessionizer opens fzf.
TS_SEARCH_PATHS=(
  ~/Desktop/p:2
  ~/ghq:3
  ~/.config:2
)

TS_MAX_DEPTH=2

# Add long-running per-session commands here, then call:
#   tmux-sessionizer -s 0
# TS_SESSION_COMMANDS=(nvim "pnpm dev")

tmux

prefix is ctrl+/, panes move with h j k l, every new window starts in the current directory, and prefix z zooms the other pane. prefix f runs the project switcher.

curl -fsSL https://www.elregaldo.com/uses/tmux.conf --create-dirs -o ~/.config/tmux/tmux.conf
tmux.conf (show)
# prefix is Ctrl+/ (one finger, next to right shift)
unbind C-b
set -g prefix C-_
bind C-_ send-prefix

# colors, windows start at 1, mouse, vi keys
set -g default-terminal "tmux-256color"
set -as terminal-overrides ",*:RGB"
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
set -g mouse on
set -g history-limit 50000
set -g escape-time 10
set -g focus-events on
set -g set-clipboard on
set -g detach-on-destroy off
setw -g aggressive-resize on
setw -g mode-keys vi

# Ctrl+1..9 jumps to a window
bind -n C-1 select-window -t 1
bind -n C-2 select-window -t 2
bind -n C-3 select-window -t 3
bind -n C-4 select-window -t 4
bind -n C-5 select-window -t 5
bind -n C-6 select-window -t 6
bind -n C-7 select-window -t 7
bind -n C-8 select-window -t 8
bind -n C-9 select-window -t 9

# copy mode (macOS clipboard; use xclip or wl-copy on linux)
bind y copy-mode
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"

# new windows and splits keep the current directory
bind c new-window -c "#{pane_current_path}"
bind n new-window -c "#{pane_current_path}" "nvim"
bind g new-window -c "#{pane_current_path}" "sh -c 'lazygit; tmux kill-window'"
bind | split-window -h -c "#{pane_current_path}"
bind _ split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

# vim pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# zoom the OTHER pane instead of the current one
bind z run-shell "tmux select-pane -t ':.{next}' && tmux resize-pane -Z"

# windows and sessions
bind x kill-window
bind q confirm-before -p "Kill session #S? (y/n)" "kill-session"
bind K confirm-before -p "Kill ALL sessions? (y/n)" "kill-server"
bind R command-prompt -I "#S" "rename-session '%%'"
bind r source-file ~/.config/tmux/tmux.conf

# project switcher: needs tmux-sessionizer in ~/.local/bin
bind -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer"

# window names are the current folder, pane borders and status bar
set -g automatic-rename on
set -g automatic-rename-format '#{b:pane_current_path}'
set -g set-titles on
set -g set-titles-string '#h:#W'
set -g pane-border-style fg=colour236
set -g pane-active-border-style fg=green
set -g pane-border-lines heavy
set -g status-position bottom
set -g status-style bg=green,fg=black,bold
set -g status-left ""
set -g status-right ""
set -g window-status-separator ""
set -g window-status-format " #I:#W "
set -g window-status-current-format " #I:#W "
set -g window-status-current-style fg=green,bg=black,bold

kitty

FiraCode Nerd Font, tokyo night, 80% opacity with blur, beam cursor with a trail, new tabs open in the current directory.

curl -fsSL https://www.elregaldo.com/uses/kitty.conf --create-dirs -o ~/.config/kitty/kitty.conf
kitty.conf (show)
font_family FiraCode Nerd Font
font_size 20.0
window_padding_width 0
background_opacity .80
background_blur 25
macos_option_as_alt yes
hide_window_decorations titlebar-only
enable_audio_bell no
scrollback_lines 20000
shell_integration enabled
copy_on_select clipboard
mouse_hide_wait 0

# a beam cursor with a short trail
cursor_shape beam
cursor_blink_interval 0
cursor_trail 1

tab_bar_style powerline
tab_powerline_style slanted
tab_bar_edge bottom

# new windows and tabs open in the current directory
map cmd+enter launch --cwd=current --type=window
map cmd+t launch --cwd=current --type=tab
map cmd+w close_window
map cmd+shift+] next_tab
map cmd+shift+[ previous_tab
map cmd+k clear_terminal scroll active
map cmd+backspace send_text all \x15

# tokyo night
foreground #c0caf5
background #1a1b26
selection_foreground #1a1b26
selection_background #c0caf5
cursor #c0caf5
url_color #73daca
active_border_color #7aa2f7
inactive_border_color #414868
bell_border_color #e0af68
active_tab_foreground #1a1b26
active_tab_background #7aa2f7
inactive_tab_foreground #c0caf5
inactive_tab_background #414868
color0 #15161e
color1 #f7768e
color2 #9ece6a
color3 #e0af68
color4 #7aa2f7
color5 #bb9af7
color6 #7dcfff
color7 #a9b1d6
color8 #414868
color9 #f7768e
color10 #9ece6a
color11 #e0af68
color12 #7aa2f7
color13 #bb9af7
color14 #7dcfff
color15 #c0caf5

starship prompt

username, full directory, a green $. no git branch, no second line.

curl -fsSL https://www.elregaldo.com/uses/starship.toml --create-dirs -o ~/.config/starship.toml
starship.toml (show)

[character]
success_symbol = '[\$](bold green)'

[username]
style_user = '#a6aaf1 bold'
style_root = 'white bold'
format = '[$user]($style)'
disabled = false
show_always = true

[hostname]
ssh_only = true
format = '[@](white bold)[$hostname](#50fa7b bold)'
disabled = false

[directory]
style = '#00a5ff bold'
truncation_length = 0
truncate_to_repo = false

these are copied from my machine. read a file before you run it. back up your own config first.