From dfb394ea214e43cbd724353289118bc0e3164681 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sun, 13 Apr 2025 22:19:45 -0700 Subject: [PATCH] add tmux back and update --- flake.lock | 30 +++++------ home.nix | 2 + programs/default.nix | 1 + programs/tmux/default.nix | 35 +++++++++++++ programs/tmux/tmux.conf | 102 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 15 deletions(-) create mode 100644 programs/tmux/default.nix create mode 100644 programs/tmux/tmux.conf diff --git a/flake.lock b/flake.lock index 9a49683..a97ff16 100644 --- a/flake.lock +++ b/flake.lock @@ -28,11 +28,11 @@ ] }, "locked": { - "lastModified": 1744223888, - "narHash": "sha256-reYpe0J1J+wH34JFs7KKp0G5nP7+XSQ5z0ZLFJcfJr8=", + "lastModified": 1744735751, + "narHash": "sha256-OPpfgL3qUIbQdbmp1/ZwnlsuTLooHN4or0EABnZTFRY=", "owner": "nix-community", "repo": "home-manager", - "rev": "79461936709b12e17adb9c91dd02d1c66d577f09", + "rev": "db7738e67a101ad945abbcb447e1310147afaf1b", "type": "github" }, "original": { @@ -48,11 +48,11 @@ ] }, "locked": { - "lastModified": 1744224272, - "narHash": "sha256-cqePj5nuC7flJWNncaVAFq1YZncU0PSyO0DEqGn+vYc=", + "lastModified": 1744478979, + "narHash": "sha256-dyN+teG9G82G+m+PX/aSAagkC+vUv0SgUw3XkPhQodQ=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "113883e37d985d26ecb65282766e5719f2539103", + "rev": "43975d782b418ebf4969e9ccba82466728c2851b", "type": "github" }, "original": { @@ -63,11 +63,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1744157173, - "narHash": "sha256-bWSjxDwq7iVePrhmA7tY2dyMWHuNJo8knkO4y+q4ZkY=", + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6a39c6e495eefabc935d8ddf66aa45d85b85fa3f", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", "type": "github" }, "original": { @@ -79,11 +79,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1744098102, - "narHash": "sha256-tzCdyIJj9AjysC3OuKA+tMD/kDEDAF9mICPDU7ix0JA=", + "lastModified": 1744463964, + "narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c8cd81426f45942bb2906d5ed2fe21d2f19d95b7", + "rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650", "type": "github" }, "original": { @@ -100,11 +100,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1744267403, - "narHash": "sha256-tPzYG/n1PP6Bp4MeJfyp9Ng/bQc4vltIBknBBkwLK3I=", + "lastModified": 1744779422, + "narHash": "sha256-CQDbwo7yYV5q0iVJ+h8+jrHmAdES2pEQyL5UeQkProE=", "owner": "nix-community", "repo": "nur", - "rev": "cb85fb3dd03d43c2db28dadb43d9bb54857b1150", + "rev": "d4312945f8ea7252952fcf694f0c6324acac5334", "type": "github" }, "original": { diff --git a/home.nix b/home.nix index 0913ae7..319e4cc 100644 --- a/home.nix +++ b/home.nix @@ -70,6 +70,7 @@ nixfmt-rfc-style nix-prefetch-git nodejs + noto-fonts ollama openssl pandoc @@ -96,6 +97,7 @@ tectonic texlab tig + tmux-sessionizer tokei tree tree-sitter diff --git a/programs/default.nix b/programs/default.nix index 4ab53ad..36307f9 100644 --- a/programs/default.nix +++ b/programs/default.nix @@ -5,6 +5,7 @@ ./git ./jujutsu ./kitty + ./tmux ./wezterm ./vscode ./zed diff --git a/programs/tmux/default.nix b/programs/tmux/default.nix new file mode 100644 index 0000000..0fba6c6 --- /dev/null +++ b/programs/tmux/default.nix @@ -0,0 +1,35 @@ +{ pkgs, ... }: + +let + tmuxConfig = builtins.readFile ./tmux.conf; +in +{ + programs.tmux = { + enable = true; + baseIndex = 1; + escapeTime = 10; + historyLimit = 10000; + keyMode = "vi"; + prefix = "C-a"; + terminal = "xterm-256color"; + extraConfig = tmuxConfig; + plugins = with pkgs.tmuxPlugins; [ + sensible + yank + kanagawa + { + plugin = kanagawa; + extraConfig = '' + set -g @kanagawa-theme 'wave' + set -g @kanagawa-plugins "cpu-usage git" + set -g @kanagawa-show-powerline true + set -g @kanagawa-refresh-rate 10 + + set -g status-right " #(tms sessions)" + bind -r '(' switch-client -p\; refresh-client -S + bind -r ')' switch-client -n\; refresh-client -S + ''; + } + ]; + }; +} diff --git a/programs/tmux/tmux.conf b/programs/tmux/tmux.conf new file mode 100644 index 0000000..cfdfa5b --- /dev/null +++ b/programs/tmux/tmux.conf @@ -0,0 +1,102 @@ +########################## +# Configuration +########################### + +# use 256 xterm for pretty colors. This enables same colors from iTerm2 within tmux. +# This is recommended in neovim :healthcheck +# set -g default-terminal "screen-256color" +# set -ga terminal-overrides ",xterm-256color:Tc" + +# disable mouse +set -g mouse off + +# decrease command delay (increases vim responsiveness) +set -sg escape-time 1 + +# increase repeat time for repeatable commands +set -g repeat-time 1000 + +# start pane index at 1 instead of 0 +setw -g pane-base-index 1 + +# highlight window when it has new activity +setw -g monitor-activity on +set -g visual-activity on + +# re-number windows when one is closed +set -g renumber-windows on + +# enable pbcopy and pbpaste +# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/README.md +# set-option -g default-command "reattach-to-user-namespace -l zsh" + +########################### +# Key Bindings +########################### + +# Tmux prefix +# Current solution is to keep the default +# and have term map C-; to C-b. This is the nicest +# bind I've found and this is the only way to enable it in tmux +# unbind C-b +# set -g prefix C-a +# bind C-a send-prefix + +# Copy vim style +# create 'v' alias for selecting text +bind Escape copy-mode +bind C-[ copy-mode +bind -T copy-mode-vi 'v' send -X begin-selection +# copy with 'enter' or 'y' and send to mac os clipboard: http://goo.gl/2Bfn8 +unbind -T copy-mode-vi Enter +bind -T copy-mode-vi Enter send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" +bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" +# paste +bind p paste-buffer +# paste from system clipboard MacOS +# bind C-v run \"tmux set-buffer \"$(reattach-to-user-namespace pbpaste)\"; tmux paste-buffer" + +# panes: window splitting +unbind % +bind "'" split-window -h +unbind '"' +bind - split-window -v + +# Switch panes with hjkl +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +# Quick window selection +bind -r C-h select-window -t :- +bind -r C-l select-window -t :+ + +# resize panes +bind -r H resize-pane -L 5 +bind -r J resize-pane -D 5 +bind -r K resize-pane -U 5 +bind -r L resize-pane -R 5 + +## Quickly switch panes +unbind ^J +bind ^J select-pane -t :.+ + +############################ +## Status Bar +############################ + +# enable UTF-8 support in status bar +set -gq status-utf8 on + +# center the status bar +set -g status-justify centre + +# show session, window, pane in left status bar +set -g status-left-length 40 +set -g status-left '#[fg=green] #S #[fg=yellow]#I/#[fg=cyan]#P ' + +# update status bar info +set -g status-interval 60 + +set -g default-command /etc/profiles/per-user/salar/bin/fish