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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
{ config
, pkgs
, ...
}:
let
cmus-np = pkgs.writeScriptBin "cmus-np" ''
${pkgs.cmus}/bin/cmus-remote -Q | awk '
/tag artist/ { $1=$2=""; artist = substr($0,3) }
/tag title/ { $1=$2=""; title = substr($0,3) }
END { printf "%s · %s\n", artist, title}
'
'';
cmus-status = pkgs.writeScriptBin "cmus-status" ''
${pkgs.cmus}/bin/cmus-remote -Q | awk '/status/ { print $2 }'
'';
date-bst = pkgs.writeScriptBin "date-bst" ''
env TZ=Europe/London date +"%H%M"
'';
# plugins
thumbs = {
plugin = pkgs.tmuxPlugins.tmux-thumbs;
extraConfig = ''
set -g @thumbs-key F
set -g @thumbs-command 'echo -n {} | xclip -i -sel p -f | xclip -i -sel c'
set -g @thumbs-fg-color white
set -g @thumbs-hint-bg-color yellow
set -g @thumbs-hint-fg-color black
set -g @thumbs-position left
set -g @thumbs-alphabet colemak-homerow
'';
};
resurrect = {
plugin = pkgs.tmuxPlugins.resurrect;
extraConfig =
let
processes = builtins.map (name: ''"~${name}->${name}"'') [
".firefox-wrapped"
"weechat --run-command ;"
];
in
''
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-dir '~/.local/share/tmux/resurrect'
set -g @resurrect-processes '${builtins.toString processes}'
set -g @resurrect-strategy-nvim 'session'
'';
};
continuum = {
plugin = pkgs.tmuxPlugins.continuum;
extraConfig = ''
set -g @continuum-restore 'on'
set -g @continuum-save-interval '20' # minutes
'';
};
in
{
programs.tmux = {
enable = true;
plugins = [ thumbs resurrect continuum ];
prefix = "C-t";
keyMode = "vi";
terminal = "xterm-256color-italic";
extraConfig = ''
unbind-key C-b
bind-key C-t send-prefix
bind r source-file ~/.config/tmux/tmux.conf
set escape-time 20
set -g mouse on
set -g base-index 1
setw -g pane-base-index 1
# session jumper
bind C-j display-popup -E "\
tmux list-sessions -F '#{session_name}' |\
fzf |\
xargs tmux switch-client -t"
# pane binds
unbind-key E
bind-key h select-pane -L
bind-key n select-pane -D
bind-key e select-pane -U
bind-key i select-pane -R
bind-key -r H resize-pane -L 5
bind-key -r N resize-pane -D 5
bind-key -r E resize-pane -U 5
bind-key -r I resize-pane -R 5
# window binds
bind -n M-h previous-window
bind -n M-i next-window
bind-key "{" split-window -h -c "#{pane_current_path}"
bind-key "}" split-window -v -c "#{pane_current_path}"
bind-key s choose-session
bind-key c new-window -c "#{pane_current_path}"
bind-key ) swap-window -t +1
bind-key ( swap-window -t -1
bind-key [ copy-mode
# statusline hide / unhide
bind -n M-down set -q status off
bind -n M-up set -q status on
bind-key -r "<" swap-window -d -t -1
bind-key -r ">" swap-window -d -t +1
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -i -sel p -f | xclip -i -sel c "
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
bind P paste-buffer
set-window-option -g allow-rename off
set -g pane-border-style fg=colour11
set -g pane-active-border-style fg=colour8
set-option -g status-justify absolute-centre
set-option -g status-position top
set -g window-status-current-format " #[fg=colour15]#W#{?window_zoomed_flag, #[fg=colour2]+,}#{?window_activity_flag, #[fg=colour3]!,}"
set -g window-status-format " #[fg=colour8]#W#{?window_zoomed_flag, #[fg=colour2]+,}"
# status right
set -g status-style "bg=colour0"
set -ag status-style "fg=colour7"
set status-right-length 70
set -g status-right "#[fg=colour15]#(date +"%H%M") #[fg=colour8]IST "
set -ag status-right "#[fg=colour15]#(${date-bst}/bin/date-bst) #[fg=colour8]BST "
set -ag status-right "#[fg=colour15]#(date +"%d/%m")#[fg=colour8] #(date +"%Y")"
# status left
set status-left-length 70
# set -g status-left "#[fg=colour15]#(${cmus-np}/bin/cmus-np) #[fg=colour8]#(${cmus-status}/bin/cmus-status) "
set -g status-left "#[fg=colour7]#(bat -q) "
set -ag status-left "#[fg=colour7]#(${pkgs.prompt}/bin/prompt cwd '#{pane_current_path}')"
'';
};
}
|