nix/programs/tmux.nix (view raw)
1{ config
2, pkgs
3, ...
4}:
5
6{
7 programs.tmux = {
8 enable = true;
9 plugins = with pkgs; [
10 {
11 plugin = tmuxPlugins.resurrect;
12 extraConfig = "set -g @resurrect-strategy-nvim 'session'";
13 }
14 ];
15 extraConfig = ''
16 set -g prefix C-q
17 set -g set-titles on
18 set-option -g set-titles-string "#T"
19 unbind-key C-b
20 bind-key C-q send-prefix
21 set -g update-environment "KEYBOARD_LAYOUT"
22
23 setw -g mode-keys vi
24
25 bind r source-file ~/.config/tmux/tmux.conf
26
27 set-option -g default-terminal xterm-256color-italic
28 set -as terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[2 q'
29 set escape-time 20
30
31 set -g mouse on
32
33 set -g base-index 1
34 setw -g pane-base-index 1
35
36 # pane binds
37 bind -n M-n select-pane -D
38 bind -n M-e select-pane -U
39 bind -n M-y select-pane -L
40 bind -n M-o select-pane -R
41 bind -n M-Up resize-pane -U 5
42 bind -n M-Down resize-pane -D 5
43 bind -n M-Left resize-pane -L 5
44 bind -n M-Right resize-pane -R 5
45
46 # window binds
47 bind -n C-M-y previous-window
48 bind -n C-M-o next-window
49 bind-key c split-window -h -c "#{pane_current_path}"
50 bind-key v new-window -c "#{pane_current_path}"
51 bind-key s choose-session
52 bind-key ) swap-window -t +2
53 bind-key ( swap-window -t -1
54
55 unbind -T copy-mode MouseDragEnd1Pane
56 bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -sel c"
57 bind-key -T copy-mode-vi v send-keys -X begin-selection
58 bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -sel c"
59 bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
60 bind P paste-buffer
61
62 # pop-up pane to open urls
63 bind-key u display-popup -E "xurls"
64
65 # statusline on top
66 set-option -g status-position top
67
68 # statusline hide / unhide
69 bind -n C-down set -q status off
70 bind -n C-up set -q status on
71 bind P paste-buffer
72
73 set-window-option -g allow-rename off
74
75 set -g pane-border-style fg=colour11
76 set -g pane-active-border-style fg=colour8
77
78 set -g status-justify right
79 set -g status-right ""
80 set -g status-left ""
81 set -g status-style "bg=colour0"
82 set -ag status-style "fg=colour7"
83
84 set -g window-status-current-format "#[fg=colour15] #W"
85 set -g window-status-format "#[fg=colour8] #W"
86
87 set -g status-left-length 100
88 if-shell '[[ $HOSTNAME != methi ]]' {
89 set -ag status-left "#[fg=colour8]cwd #[fg=colour15]#(${pkgs.prompt}/bin/prompt cwd #{pane_current_path}) "
90 set -ag status-left "#[fg=colour8]#(${pkgs.prompt}/bin/prompt vcs #{pane_current_path}) "
91 }
92
93 # dim inactive pane
94 set -g window-style 'fg=color8,bg=default'
95 set -g window-active-style 'fg=color7,bg=default'
96 '';
97 };
98}