This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / tools / tmux / flake-module.nix
3.1 kB 74 lines
1{ self, inputs, ... }: 2{ 3 perSystem = 4 { pkgs, ... }: 5 let 6 sessionManager = pkgs.writeShellScript "tmux-session-manager" '' 7 while true; do 8 existing=$(tmux list-sessions -F '#{session_name}: #{session_windows} windows (created #{session_created_string})#{?session_attached, (attached),}' 2>/dev/null) 9 [[ -z "$existing" ]] && break 10 chosen=$(echo -e ">>> new session <<<\n$existing" \ 11 | ${pkgs.fzf}/bin/fzf --height=80% --reverse \ 12 --header="Pick a tmux session (DEL to kill)" \ 13 --expect=delete \ 14 --preview='s={1}; s=''${s%:}; [ "$s" = ">>>" ] && echo "Create a new session" || tmux capture-pane -t "$s" -p -e 2>/dev/null' \ 15 --preview-window=down:50%) 16 key=$(echo "$chosen" | head -1) 17 selection=$(echo "$chosen" | tail -1) 18 chosen_name=$(echo "$selection" | cut -d: -f1) 19 if [[ "$key" == "delete" && -n "$chosen_name" && "$chosen_name" != ">>> new session <<<" ]]; then 20 tmux kill-session -t "$chosen_name" 2>/dev/null 21 continue 22 fi 23 if [[ -n "$chosen_name" && "$chosen_name" != ">>> new session <<<" ]]; then 24 tmux switch-client -t "$chosen_name" 25 exit 0 26 fi 27 break 28 done 29 # Create a new session 30 session_name=$(${ 31 self.packages.${pkgs.system}.name-generator 32 }/bin/name-generator 2>/dev/null || echo "session-$$") 33 tmux new-session -d -s "$session_name" 34 tmux switch-client -t "$session_name" 35 ''; 36 tmuxConfigText = '' 37 set-option -g default-terminal screen-256color 38 39 # Enable extended keys (CSI u / modified key sequences) 40 set -s extended-keys on 41 set -as terminal-features 'xterm*:extkeys' 42 43 # Enable kitty graphics protocol passthrough 44 set -g allow-passthrough on 45 set -ga update-environment TERM 46 set -ga update-environment TERM_PROGRAM 47 48 # Session manager popup (prefix + s) 49 bind s display-popup -E -w 80% -h 80% "${sessionManager}" 50 # tmux 3.7 stopped entering copy-mode on wheel/drag over alternate-screen 51 # panes and forwards the events to the app instead (issue 3705), which 52 # breaks scrolling around omp's fullscreen overlays. Pin the 3.6 53 # behavior: only hand the mouse to apps that track it themselves. 54 bind -n WheelUpPane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -e } } 55 bind -n MouseDrag1Pane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -M } } 56 ''; 57 tmuxConfigFile = pkgs.writeText "tmux.conf" tmuxConfigText; 58 in 59 { 60 packages.tmux = 61 (inputs.wrappers.lib.wrapPackage { 62 pkgs = pkgs; 63 package = pkgs.tmux; 64 flags = { 65 "-f" = "${tmuxConfigFile}"; 66 }; 67 }).overrideAttrs 68 (old: { 69 passthru = (old.passthru or { }) // { 70 tmuxConfig = tmuxConfigText; 71 }; 72 }); 73 }; 74}