tmux.nix 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. { pkgs
  2. , config
  3. , lib
  4. , ...
  5. }:
  6. let
  7. isDarwin = pkgs.stdenv.isDarwin;
  8. reattach-to-user-namespace = lib.getExe' pkgs.reattach-to-user-namespace "reattach-to-user-namespace";
  9. lazygit = lib.getExe pkgs.lazygit;
  10. shell = lib.getExe config.programs.fish.package;
  11. in
  12. {
  13. home.packages = with pkgs; [ eza ];
  14. programs.sesh = {
  15. enable = true;
  16. settings = {
  17. dir_length = 2;
  18. default_session.startup_command = "nvim -c \"lua vim.defer_fn(function() require('telescope.builtin').find_files() end, 0)\"";
  19. default_session.preview_command = "eza --all --git --icons --color=always {}";
  20. };
  21. };
  22. programs.fzf.tmux.enableShellIntegration = true;
  23. programs.tmux = {
  24. sensibleOnTop = true;
  25. baseIndex = 1;
  26. clock24 = true;
  27. enable = true;
  28. escapeTime = 10;
  29. keyMode = "vi";
  30. focusEvents = true;
  31. mouse = true;
  32. prefix = "C-b";
  33. shell = "${lib.getExe config.programs.fish.package}";
  34. terminal = "tmux-256color";
  35. plugins = with pkgs.tmuxPlugins; [
  36. tmux-select-pane-no-wrap
  37. vim-tmux-navigator
  38. yank
  39. {
  40. plugin = kanagawa;
  41. extraConfig = ''
  42. set -g status-position top
  43. set -g @kanagawa-theme 'dragon'
  44. set -g @kanagawa-refresh-rate 60
  45. set -g @kanagawa-show-left-icon window
  46. set -g @kanagawa-show-battery true
  47. set -g @kanagawa-show-powerline true
  48. # set -g @kanagawa-show-left-sep 
  49. # set -g @kanagawa-show-right-sep 
  50. # set -g @kanagawa-show-left-sep 
  51. # set -g @kanagawa-show-right-sep 
  52. # set -g @kanagawa-show-left-sep 
  53. # set -g @kanagawa-show-right-sep 
  54. # set -g @kanagawa-show-left-sep 
  55. # set -g @kanagawa-show-right-sep 
  56. set -g @kanagawa-show-left-sep 
  57. set -g @kanagawa-show-right-sep 
  58. set -g @kanagawa-show-location false
  59. set -g @kanagawa-ignore-window-colors true
  60. '';
  61. }
  62. ];
  63. extraConfig = ''
  64. ${lib.optionalString isDarwin ''
  65. # sensible plugin assumes $SHELL is /bin/sh
  66. # --- Darwin-Specific Settings (Raw Tmux Commands) ---
  67. # This block is only included if the system is Darwin
  68. set-option -g default-command "${reattach-to-user-namespace} -l $SHELL"
  69. ''}
  70. # split windows on the current path
  71. unbind %
  72. unbind '"'
  73. bind-key % split-window -h -c '#{pane_current_path}'
  74. bind-key '"' split-window -v -c '#{pane_current_path}'
  75. # resize pane with vim motion keys
  76. bind-key -r h resize-pane -L 1
  77. bind-key -r l resize-pane -R 1
  78. bind-key -r j resize-pane -D 1
  79. bind-key -r k resize-pane -U 1
  80. # move between tmux windows
  81. bind-key -n C-e select-window -t :1
  82. bind-key -n C-a select-window -t :2
  83. # some display popups
  84. bind-key -n C-g display-popup -d "#{pane_current_path}" -w 80% -h 80% -E "${lazygit}"
  85. bind-key -n C-t display-popup -d "#{pane_current_path}" -w 75% -h 75% -E "${shell}"
  86. # sesh
  87. bind-key -n C-s run-shell "sesh connect \"$(
  88. sesh list --icons | fzf --tmux 80%,70% \
  89. --no-sort --ansi --border-label ' sesh ' --prompt '⚡ ' \
  90. --header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
  91. --bind 'tab:down,btab:up' \
  92. --bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list --icons)' \
  93. --bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list --icons -t)' \
  94. --bind 'ctrl-g:change-prompt(⚙️ )+reload(sesh list --icons -c)' \
  95. --bind 'ctrl-x:change-prompt(📁 )+reload(sesh list --icons -z)' \
  96. --bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
  97. --bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list --icons)' \
  98. --preview-window 'right:55%' \
  99. --preview 'sesh preview {}' \
  100. -- --ansi
  101. )\""
  102. # kill pane
  103. bind-key x kill-pane
  104. set -g detach-on-destroy off
  105. '';
  106. };
  107. }