{ 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 { if(artist&&title) printf "%s / %s\n", artist, title} ' ''; cmus-status = pkgs.writeScriptBin "cmus-status" '' # ${pkgs.cmus}/bin/cmus-remote -Q | awk '/status/ { print $2 }' ${pkgs.cmus}/bin/cmus-remote -Q | awk ' /status/ && $2~/playing/ { print "||" } /status/ && $2~/paused/ { print "|>" } /status/ && $2~/stopped/ { print "ยท" } ' ''; date-tz = tz: pkgs.writeScriptBin "date" '' env TZ=${tz} date +"%H%M" ''; date-ist = date-tz "Asia/Kolkata"; date-bst = date-tz "Europe/London"; date-hel = date-tz "Europe/Helsinki"; copy = "${pkgs.wl-clipboard-rs}/bin/wl-copy"; paste = "${pkgs.wl-clipboard-rs}/bin/wl-paste"; # plugins thumbs = { plugin = pkgs.tmuxPlugins.tmux-thumbs; extraConfig = '' set -g @thumbs-key F set -g @thumbs-command 'echo -n {} | ${copy}' 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}"'') [ "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}' ''; }; in { programs.tmux = { enable = true; plugins = [ thumbs ]; prefix = "C-t"; keyMode = "vi"; terminal = "alacritty"; extraConfig = '' 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-key -n C-h run-shell "tmux-fzf" # 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 -n M-? switch-client -p bind -n M-/ switch-client -n 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 -sq status off\; set -sq pane-border-status off bind -n M-up set -sq status on\; set -sq pane-border-status top 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 "${copy}" bind-key -T copy-mode-vi r send-keys -X rectangle-toggle bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "${copy}" bind P paste-buffer set-window-option -g allow-rename off set-option -g status-justify absolute-centre set-option -g status-position bottom 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 -g status-right-length 70 set -g status-right "#[fg=colour15]#(${date-ist}/bin/date) #[fg=colour8]IST " set -ag status-right "#[fg=colour15]#(${date-hel}/bin/date) #[fg=colour8]HEL " set -ag status-right "#[fg=colour15]#(${date-bst}/bin/date) #[fg=colour8]BST " set -ag status-right "#[fg=colour15]#(date +"%d/%m")#[fg=colour8] #(date +"%Y")" # status left set -g status-left-length 70 set -g status-left "#[fg=colour7]#(bat -q) " # set -ag status-left "#[fg=colour15]#(${cmus-np}/bin/cmus-np) #[fg=colour8]#(${cmus-status}/bin/cmus-status)" # include pwd and branch in pane border set -g pane-border-status top set -g pane-border-style fg=colour11 set -g pane-active-border-style fg=colour8 set -g pane-border-format " #[fg=colour15]#(${pkgs.prompt}/bin/prompt cwd '#{pane_current_path}') " set -ag pane-border-format "#[fg=colour8]#(${pkgs.prompt}/bin/prompt vcs '#{pane_current_path}') " # popup styles set -g popup-border-style "fg=colour8" # load all sessions source-file ~/.config/tmux/sessions/all ''; }; }