# tmux status bar integration for muxx
# Add the relevant lines to ~/.tmux.conf

# Option 1: Use tmux's built-in #S variable (recommended — no subprocess)
# Displays the current session name in the left status bar.
set -g status-left "[#S] "

# Option 2: Use `muxx current` if you want output filtered through muxx
# This spawns a subprocess on every status refresh — use sparingly.
# set -g status-left "#(muxx current) "

# Refresh the status bar every 5 seconds (only matters if using option 2)
# set -g status-interval 5

# Keybind: open a new muxx session for the current directory from within tmux.
# Press prefix + M to run `muxx connect` in a new window.
bind M new-window "muxx connect --no-attach; tmux switch-client -l"

# Keybind: prefix + S to pick a session via fzf (requires fzf in PATH).
bind S run-shell 'tmux new-window "muxx list --json | \
  python3 -c \"import json,sys; [print(s[\\\"name\\\"]) for s in json.load(sys.stdin)]\" | \
  fzf --prompt=\"session> \" --height=10 --reverse | xargs -r muxx connect"'
