From 0a6eae2a61d525de538455d63976663c0286a53e Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Wed, 28 Jul 2021 22:32:49 -0700 Subject: [PATCH] add tmux --- programs/default.nix | 1 + programs/neovim/init.lua | 1 + programs/tmux/default.nix | 38 +++++++++++++ programs/tmux/tmux.conf | 110 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 programs/tmux/default.nix create mode 100644 programs/tmux/tmux.conf diff --git a/programs/default.nix b/programs/default.nix index 47ef687..6a06b79 100644 --- a/programs/default.nix +++ b/programs/default.nix @@ -1,4 +1,5 @@ [ ./git # ./neovim + ./tmux ] diff --git a/programs/neovim/init.lua b/programs/neovim/init.lua index e4d66b7..1881df7 100644 --- a/programs/neovim/init.lua +++ b/programs/neovim/init.lua @@ -38,6 +38,7 @@ local function load_plugins() use 'gennaro-tedesco/nvim-jqx' use 'kristijanhusak/orgmode.nvim' use 'p00f/nvim-ts-rainbow' + use 'christoomey/vim-tmux-navigator' end) end diff --git a/programs/tmux/default.nix b/programs/tmux/default.nix new file mode 100644 index 0000000..90cb547 --- /dev/null +++ b/programs/tmux/default.nix @@ -0,0 +1,38 @@ +{ config, 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; [ + { + plugin = tmuxPlugins.resurrect; + extraConfig = "set -g @resurrect-strategy-nvim 'session'"; + } + { + plugin = tmuxPlugins.continuum; + extraConfig = "set -g @continuum-restore 'on'"; + } + { + plugin = tmuxPlugins.sensible; + } + { + plugin = tmuxPlugins.vim-tmux-navigator; + } + { + plugin = tmuxPlugins.onedark-theme; + } + ]; + }; +} + diff --git a/programs/tmux/tmux.conf b/programs/tmux/tmux.conf new file mode 100644 index 0000000..e2b72b3 --- /dev/null +++ b/programs/tmux/tmux.conf @@ -0,0 +1,110 @@ +########################## +# 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 + +########################### +# Colors +########################### + +# onedark color scheme +set -g @onedark_widgets "#(date +%s)" +set -g @onedark_time_format "%I:%M %p" +set -g @onedark_date_format "%D" +