1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
set -g default-terminal "tmux-256color"
set -g base-index 1

# seems to mess w/the bottom prompt
# set -g allow-passthrough on

# RGB color: https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-rgb-colour
set -as terminal-features ",gnome*:RGB"

## window notifications
set -g visual-activity on
set -g monitor-activity off

## title
set -g set-titles on
set -g set-titles-string "[#S] #I:#W"
set -g automatic-rename on

## mouse
# It's nice to be able to resize using the mouse, but it turns out that I
# like clicking on URLs even more, and this breaks that.
set -g mouse on

## keyboard
set -g mode-keys vi
set -ga terminal-features "*:hyperlinks" # osc 8
set -g extended-keys on
set -g extended-keys-format csi-u # pi

# copy and paste
bind -T copy-mode-vi 'v' send -X begin-selection
bind -T copy-mode-vi 'V' send -X select-line
bind -T copy-mode-vi 'r' send -X rectangle-toggle
bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel pbcopy
bind -T copy-mode-vi 'H' send -X start-of-line
bind -T copy-mode-vi 'L' send -X end-of-line
bind -T copy-mode-vi o run-shell -C \
  "if-shell -F '#{selection_hyperlink}' 'run-shell open #{selection_hyperlink}' 'send-keys -X copy-pipe-and-cancel \"xargs open\"'"

# colors
set -g pane-active-border-style "fg=brightred"
set -g pane-border-style "bg=#333333"
set -g pane-border-status top
set -g pane-border-format ' #{?pane_title,#{pane_title},#{pane_current_command}} '

set-hook -g pane-focus-out 'select-pane -P bg=#333333,fg=default'
set-hook -g pane-focus-in 'select-pane -P bg=default,fg=default'

# statusline (shamelessly stolen from powerline)
set -g status-left "#{?client_prefix,#[fg=color254]#[bg=color24]#[bold]#[noitalics]#[nounderscore],#[fg=color232]#[bg=color254]#[noitalics]#[nounderscore]} #S #{?client_prefix,#[fg=color31],#[fg=color254]}#[bg=terminal]#[nobold] "
set -g status-left-length 20
set -g status-right ""
set -g status-style fg=color231,bg=terminal

set -g window-status-activity-style fg=color11,bg=terminal
set -g window-status-bell-style fg=color1,bg=terminal
set -g window-status-current-format "#[fg=terminal,bg=color24,nobold,noitalics,nounderscore] #[fg=color231,bg=color24,nobold,noitalics,nounderscore]#F#[fg=color231,bg=color24,nobold,noitalics,nounderscore]#W #[fg=color31,bg=terminal,nobold,noitalics,nounderscore]"
set -g window-status-format "#[fg=color244,bg=terminal,nobold,noitalics,nounderscore] #{?window_flags,#F, }#[fg=color240,bg=color0,nobold,noitalics,nounderscore]#[default]#W "
set -g window-status-last-style fg=color31,bg=terminal
set -g window-status-style fg=color249,bg=terminal

## screen bindings

bind a send-prefix

bind c new-window
bind C-c new-window

bind d detach
bind C-d detach

bind n next-window
bind C-n next-window

bind p previous-window
bind C-p previous-window

bind C-a last-window

set -g renumber-windows on;
bind c new-window -c '#{pane_current_path}';
bind C-c new-window -c '#{pane_current_path}';
bind v split-window -h -c '#{pane_current_path}';
bind s split-window -v -c '#{pane_current_path}';

# zoxide + fzf directory switcher in a floating pane; opens a new window
# named after the selected dir. -X/-Y center the pane: offset is
# (100% - size%) / 2 in each dimension. select-pane -T names the pane
# (it's current after creation, so no -t target is needed).
bind g new-pane -x 80% -y 60% -X 10% -Y 20% -e IN_TMUX_FLOAT=1 -- ~/.dotfiles/bin/,z \; select-pane -T 'zoxide';

# Claude session picker in the same floating pane, ranked so sessions blocked
# on a permission prompt sort above idle ones. Lowercase a is send-prefix.
bind A new-pane -x 80% -y 60% -X 10% -Y 20% -e IN_TMUX_FLOAT=1 -- ~/.dotfiles/ai/bin/,agents \; select-pane -T 'agents';

# ,tmux-grab in the same floating pane as above. It looks up the triggering
# pane itself via {last} — new-pane doesn't expand #{pane_id} in a
# shell-command argument, so passing it here isn't an option.
bind Tab new-pane -x 80% -y 60% -X 10% -Y 20% -e IN_TMUX_FLOAT=1 -- "~/.dotfiles/bin/,tmux-grab" \; select-pane -T 'grab';

## fzf-git (disabled — fzf-git.sh is no longer sourced in zsh)

# bind -Tfzf-git C-f send-keys C-g f
# bind -Tfzf-git C-g send-keys C-g b
# bind -Tfzf-git C-h send-keys C-g h
# bind -Troot C-g switch-client -Tfzf-git

bind r source-file ~/.config/tmux/tmux.conf \; display-message "tmux.conf reloaded"

if-shell "[[ -e ~/.config/tmux/tmux.conf.local ]]" "source-file ~/.config/tmux/tmux.conf.local"

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'christoomey/vim-tmux-navigator'

run '~/.config/tmux/plugins/tpm/tpm'