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