feat(home): tmux
This commit is contained in:
parent
5ed3ac9754
commit
804c8b98d0
3 changed files with 164 additions and 150 deletions
|
@ -41,6 +41,7 @@ in
|
|||
ssh = enabled;
|
||||
starship = enabled;
|
||||
systemctl = enabled;
|
||||
tmux = enabled;
|
||||
};
|
||||
xorg = {
|
||||
xsession = enabled;
|
||||
|
|
163
modules/home/programs/tmux/default.nix
Normal file
163
modules/home/programs/tmux/default.nix
Normal file
|
@ -0,0 +1,163 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
namespace,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib.${namespace}) mkEnableModule;
|
||||
|
||||
cfg = config.${namespace}.programs.tmux;
|
||||
inherit (config.${namespace}) theme;
|
||||
in
|
||||
{
|
||||
options = mkEnableModule "programs.tmux";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
|
||||
rose-pine = mkIf (theme.colors.base == "rose-pine") {
|
||||
enable = true;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @rose_pine_host 'on'
|
||||
set -g @rose_pine_directory 'on'
|
||||
'';
|
||||
};
|
||||
|
||||
terminal = "tmux-256color";
|
||||
|
||||
escapeTime = 0;
|
||||
|
||||
# Start window & pane numbering at 1.
|
||||
baseIndex = 1;
|
||||
|
||||
# Vi mode.
|
||||
keyMode = "vi";
|
||||
customPaneNavigationAndResize = true;
|
||||
mouse = true;
|
||||
|
||||
# Auto-spawn a new session when attaching if none exist.
|
||||
newSession = true;
|
||||
|
||||
# Key used with Ctrl to make the prefix.
|
||||
shortcut = "a";
|
||||
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
{
|
||||
plugin = resurrect;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = continuum;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @continuum-restore 'on'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = tilish;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
# Don't enforce the layout.
|
||||
set -g @tilish-enforce 'none'
|
||||
|
||||
set -g @tilish-project "$HOME/hackin"
|
||||
set -g @tilish-navigator 'on'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = vim-tmux-navigator;
|
||||
}
|
||||
|
||||
yank
|
||||
|
||||
{
|
||||
plugin = jump;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @jump-key 's'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = fingers;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @fingers-jump-key 'f'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = tmux-floax;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @floax-bind 'i'
|
||||
set -g @floax-text-color 'white'
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
extraConfig = # tmux
|
||||
''
|
||||
# Set repeat timeout so keys can be repeated without the prefix.
|
||||
set -g repeat-time 1000
|
||||
|
||||
# Auto-renumber windows when one is deleted.
|
||||
set -g renumber-windows 'on'
|
||||
|
||||
set -ag terminal-overrides ",*:RGB"
|
||||
|
||||
set -g status-position 'top'
|
||||
|
||||
### Keybindings ###
|
||||
|
||||
# Easy reload config.
|
||||
bind r source-file ${config.xdg.configHome}/tmux/tmux.conf \; display-message "Reloaded config"
|
||||
|
||||
# Better split commands.
|
||||
bind -N 'vsplit' | split-window -h -c "#{pane_current_path}"
|
||||
bind -N 'vsplit' \\ split-window -h -c "#{pane_current_path}"
|
||||
bind -N 'hsplit' - split-window -v -c "#{pane_current_path}"
|
||||
unbind '"'
|
||||
unbind %
|
||||
|
||||
# Vi-like resizing.
|
||||
bind -r -N 'Resize pane (left)' M-h resize-pane -L 5
|
||||
bind -r -N 'Resize pane (down)' M-j resize-pane -D 5
|
||||
bind -r -N 'Resize pane (up)' M-k resize-pane -U 5
|
||||
bind -r -N 'Resize pane (right)' M-l resize-pane -R 5
|
||||
|
||||
# Even out panes.
|
||||
bind -N 'Evenly distribute panes' = select-layout -E
|
||||
|
||||
# Swap panes.
|
||||
bind -r -N 'Swap current pane with the next' H swap-pane -U
|
||||
bind -r -N 'Swap current pane with the previous' L swap-pane -D
|
||||
|
||||
# Window switching.
|
||||
bind -N 'Previous window' Left previous-window
|
||||
bind -N 'Next window' Right next-window
|
||||
|
||||
# Vi copy mode.
|
||||
unbind [
|
||||
bind -N 'Enter normal (copy) mode' Escape copy-mode
|
||||
|
||||
bind -T copy-mode-vi ? command-prompt -p '?' 'send -X search-backward %1'
|
||||
bind -T copy-mode-vi / command-prompt -p '/' 'send -X search-forward %1'
|
||||
bind -T copy-mode-vi q send -X cancel
|
||||
bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' 'send -X clear-selection' 'send -X cancel'
|
||||
'';
|
||||
};
|
||||
|
||||
home.shellAbbrs = {
|
||||
tmain = "tmux new -s main -A";
|
||||
tmobile = "tmux new -s mobile -A";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
|
||||
rose-pine = {
|
||||
enable = true;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @rose_pine_host 'on'
|
||||
set -g @rose_pine_directory 'on'
|
||||
'';
|
||||
};
|
||||
|
||||
terminal = "tmux-256color";
|
||||
|
||||
escapeTime = 0;
|
||||
|
||||
# Start window & pane numbering at 1.
|
||||
baseIndex = 1;
|
||||
|
||||
# Vi mode.
|
||||
keyMode = "vi";
|
||||
customPaneNavigationAndResize = true;
|
||||
mouse = true;
|
||||
|
||||
# Auto-spawn a new session when attaching if none exist.
|
||||
newSession = true;
|
||||
|
||||
# Key used with Ctrl to make the prefix.
|
||||
shortcut = "a";
|
||||
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
{
|
||||
plugin = resurrect;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = continuum;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @continuum-restore 'on'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = tilish;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
# Don't enforce the layout.
|
||||
set -g @tilish-enforce 'none'
|
||||
|
||||
set -g @tilish-project "$HOME/hackin"
|
||||
set -g @tilish-navigator 'on'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = vim-tmux-navigator;
|
||||
}
|
||||
|
||||
yank
|
||||
|
||||
{
|
||||
plugin = jump;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @jump-key 's'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = fingers;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @fingers-jump-key 'f'
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
plugin = tmux-floax;
|
||||
extraConfig = # tmux
|
||||
''
|
||||
set -g @floax-bind 'i'
|
||||
set -g @floax-text-color 'white'
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
extraConfig = # tmux
|
||||
''
|
||||
# Set repeat timeout so keys can be repeated without the prefix.
|
||||
set -g repeat-time 1000
|
||||
|
||||
# Auto-renumber windows when one is deleted.
|
||||
set -g renumber-windows 'on'
|
||||
|
||||
set -ag terminal-overrides ",*:RGB"
|
||||
|
||||
set -g status-position 'top'
|
||||
|
||||
### Keybindings ###
|
||||
|
||||
# Easy reload config.
|
||||
bind r source-file ${config.xdg.configHome}/tmux/tmux.conf \; display-message "Reloaded config"
|
||||
|
||||
# Better split commands.
|
||||
bind -N 'vsplit' | split-window -h -c "#{pane_current_path}"
|
||||
bind -N 'vsplit' \\ split-window -h -c "#{pane_current_path}"
|
||||
bind -N 'hsplit' - split-window -v -c "#{pane_current_path}"
|
||||
unbind '"'
|
||||
unbind %
|
||||
|
||||
# Vi-like resizing.
|
||||
bind -r -N 'Resize pane (left)' M-h resize-pane -L 5
|
||||
bind -r -N 'Resize pane (down)' M-j resize-pane -D 5
|
||||
bind -r -N 'Resize pane (up)' M-k resize-pane -U 5
|
||||
bind -r -N 'Resize pane (right)' M-l resize-pane -R 5
|
||||
|
||||
# Even out panes.
|
||||
bind -N 'Evenly distribute panes' = select-layout -E
|
||||
|
||||
# Swap panes.
|
||||
bind -r -N 'Swap current pane with the next' H swap-pane -U
|
||||
bind -r -N 'Swap current pane with the previous' L swap-pane -D
|
||||
|
||||
# Window switching.
|
||||
bind -N 'Previous window' Left previous-window
|
||||
bind -N 'Next window' Right next-window
|
||||
|
||||
# Vi copy mode.
|
||||
unbind [
|
||||
bind -N 'Enter normal (copy) mode' Escape copy-mode
|
||||
|
||||
bind -T copy-mode-vi ? command-prompt -p '?' 'send -X search-backward %1'
|
||||
bind -T copy-mode-vi / command-prompt -p '/' 'send -X search-forward %1'
|
||||
bind -T copy-mode-vi q send -X cancel
|
||||
bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' 'send -X clear-selection' 'send -X cancel'
|
||||
'';
|
||||
};
|
||||
|
||||
home.shellAbbrs = {
|
||||
tmain = "tmux new -s main -A";
|
||||
tmobile = "tmux new -s mobile -A";
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue