This commit is contained in:
Salar Rahmanian 2021-07-28 22:32:49 -07:00
parent 2714a216e3
commit 0a6eae2a61
4 changed files with 150 additions and 0 deletions

View file

@ -1,4 +1,5 @@
[
./git
# ./neovim
./tmux
]

View file

@ -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

38
programs/tmux/default.nix Normal file
View file

@ -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;
}
];
};
}

110
programs/tmux/tmux.conf Normal file
View file

@ -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"