Tmux : Move config to nix.

This commit is contained in:
Dmitry Voronin 2024-02-24 21:44:25 +03:00
parent 87093e4bc6
commit 705c3ce800
23 changed files with 143 additions and 145 deletions

View file

@ -26,13 +26,13 @@
./module/common/Git.nix
./module/common/Kernel.nix
./module/common/Locale.nix
./module/common/Neovim.nix
./module/common/Network.nix
./module/common/Nix.nix
./module/common/Package.nix
./module/common/Root.nix
./module/common/Sshd.nix
./module/common/Swap.nix
./module/common/Tmux.nix
./module/common/Users.nix
./module/common/Wallpaper.nix
];

View file

@ -1,6 +1,11 @@
{ config, pkgs, ... }: {
{ config, pkgs, environment, ... }: {
imports = [ ];
# Use dedicated GPU by default.
environment.variables = {
DRI_PRIME = 1;
};
# Filesystems.
fileSystems."/storage/hot" = {
device = "/dev/storage/hot";

View file

@ -1,7 +1,12 @@
{ environment, ... }: {
security.loginDefs.settings.UMASK = "077";
environment.variables = {
# Neovim.
EDITOR = "nvim";
MANPAGER = "nvim +Man!";
# Mangohud.
MANGOHUD = "true";
MANGOHUD_CONFIGFILE = "~/.config/MangoHud/MangoHud.conf";
};
}

View file

@ -1,7 +0,0 @@
{ ... }: {
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
}

View file

@ -30,7 +30,6 @@
sqlite
steam-run
testdisk
tmux
tree
ventoy
wget
@ -40,5 +39,6 @@
];
# Special packages.
programs.adb.enable = true;
programs.adb.enable = true;
programs.neovim.enable = true;
}

View file

@ -0,0 +1,26 @@
{ ... }: {
imports = [
./tmux/Buffer.nix
./tmux/Environment.nix
./tmux/Pane.nix
./tmux/Session.nix
./tmux/Statusbar.nix
./tmux/Window.nix
];
programs.tmux = {
enable = true;
extraConfig = ''
# Remap <C-b> to <C-t>.
unbind-key C-b
set-option -g prefix C-t
bind-key C-t send-prefix
# Disable escape delay.
set -sg escape-time 0
# Reload config.
bind -n M-r source-file /etc/tmux.conf
'';
};
}

View file

@ -0,0 +1,17 @@
{ ... }: {
programs.tmux.extraConfig = ''
# Scroll.
bind -n M-p copy-mode -u
bind -n M-n send-keys Pagedown
# Copy mode.
setw -g mode-keys vi
bind -n M-v copy-mode
bind -n M-P choose-buffer
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
# Selection style.
set -g mode-style 'fg=black,bg=yellow bold'
'';
}

View file

@ -0,0 +1,6 @@
{ ... }: {
programs.tmux.extraConfig = ''
# Update environment from client.
set-option -g update-environment "SSH_CLIENT SSH_TTY DOCKER_CONFIG DOCKER_HOST DISPLAY XAUTHORITY"
'';
}

View file

@ -0,0 +1,24 @@
{ ... }: {
programs.tmux.extraConfig = ''
# Remap split keys.
bind -n M-\\ split-window -h -c "#{pane_current_path}"
bind -n M-- split-window -v -c "#{pane_current_path}"
bind -n M-= select-layout tiled
bind -n M-W resize-pane -U 1
bind -n M-S resize-pane -D 1
bind -n M-A resize-pane -L 1
bind -n M-D resize-pane -R 1
unbind '"'
unbind %
# Swith panes with alt + hjkl.
bind -n M-a select-pane -L
bind -n M-d select-pane -R
bind -n M-w select-pane -U
bind -n M-s select-pane -D
# Close pane.
bind -n M-c kill-pane
bind -n M-C kill-pane -a
'';
}

View file

@ -0,0 +1,15 @@
{ ... }: {
programs.tmux.extraConfig = ''
# Detach.
bind -n M-z detach-client
bind -n M-Z detach-client -a
# Switch sessions.
bind -n M-9 switch-client -p
bind -n M-0 switch-client -n
bind -n M-g choose-session
# Resize to smallest client.
set -g window-size smallest
'';
}

View file

@ -0,0 +1,22 @@
{ ... }: {
programs.tmux.extraConfig = ''
# Statusbar.
set -g status-interval 2
set -g status-position bottom
set -g status-justify left
set -g status-style 'bg=color236 fg=color187'
set -g status-left ' #[bold]#H-#S #(count=$(tmux list-clients -t #S | wc -l); [ $${count} -gt 1 ] && echo "($${count}) ")'
set -g status-left-length 50
set -g status-right ' #(head -c -1 /sys/class/power_supply/BAT*/capacity 2> /dev/null && echo -n "% ")#[fg=color187,bg=color239] %Y-%m-%d #[bg=color138,fg=black,bold] %H:%M '
set -g status-right-length 50
setw -g window-status-current-style 'fg=black bg=color143 bold'
setw -g window-status-current-format ' #[fg=black]#W#[fg=black]#F '
setw -g window-status-style 'fg=black bg=color138'
setw -g window-status-format ' #[fg=black]#W#[fg=black] '
setw -g window-status-bell-style 'fg=black bg=white bold'
'';
}

View file

@ -0,0 +1,19 @@
{ ... }: {
programs.tmux.extraConfig = ''
# Create new window.
bind -n M-Escape new-window -c "#{pane_current_path}"
bind -n M-t new-window -c "#{pane_current_path}" # NOTE: for compatibility reasons.
# Close window.
bind -n M-x kill-window
bind -n M-X kill-window -a
# Switch window.
bind -n M-e next-window
bind -n M-q previous-window
# Move window.
bind -n M-E swap-window -t +1\; select-window -t +1
bind -n M-Q swap-window -t -1\; select-window -t -1
'';
}

View file

@ -1,95 +0,0 @@
# Remap <C-b> to <C-t>.
unbind-key C-b
set-option -g prefix C-t
bind-key C-t send-prefix
# Disable escape delay.
set -sg escape-time 0
# Remap split keys.
bind -n M-\\ split-window -h -c "#{pane_current_path}"
bind -n M-- split-window -v -c "#{pane_current_path}"
bind -n M-= select-layout tiled
bind -n M-W resize-pane -U 1
bind -n M-S resize-pane -D 1
bind -n M-A resize-pane -L 1
bind -n M-D resize-pane -R 1
unbind '"'
unbind %
# Reload config.
bind -n M-r source-file ~/.config/tmux/tmux.conf
# Swith panes with alt + hjkl.
bind -n M-a select-pane -L
bind -n M-d select-pane -R
bind -n M-w select-pane -U
bind -n M-s select-pane -D
# Close pane.
bind -n M-c kill-pane
bind -n M-C kill-pane -a
# Create new window.
bind -n M-Escape new-window -c "#{pane_current_path}"
bind -n M-t new-window -c "#{pane_current_path}" # NOTE: for compatibility with Termux as it does not support <C-Esc> yet.
# Close window.
bind -n M-x kill-window
bind -n M-X kill-window -a
# Switch window.
bind -n M-e next-window
bind -n M-q previous-window
# Move window.
bind -n M-E swap-window -t +1\; select-window -t +1
bind -n M-Q swap-window -t -1\; select-window -t -1
# Detach.
bind -n M-z detach-client
bind -n M-Z detach-client -a
# Scroll.
bind -n M-p copy-mode -u
bind -n M-n send-keys Pagedown
# Copy mode.
setw -g mode-keys vi
bind -n M-v copy-mode
bind -n M-P choose-buffer
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
# Switch sessions.
bind -n M-9 switch-client -p
bind -n M-0 switch-client -n
bind -n M-g choose-session
# Resize to smallest client.
set -g window-size smallest
# Statusbar.
set -g status-interval 2
set -g status-position bottom
set -g status-justify left
set -g status-style 'bg=color236 fg=color187'
set -g status-left ' #[bold]#H-#S #(count=$(tmux list-clients -t #S | wc -l); [ ${count} -gt 1 ] && echo "(${count}) ")'
set -g status-left-length 50
set -g status-right ' #(head -c -1 /sys/class/power_supply/BAT*/capacity 2> /dev/null && echo -n "% ")#[fg=color187,bg=color239] %Y-%m-%d #[bg=color138,fg=black,bold] %H:%M '
set -g status-right-length 50
setw -g window-status-current-style 'fg=black bg=color143 bold'
setw -g window-status-current-format ' #[fg=black]#W#[fg=black]#F '
setw -g window-status-style 'fg=black bg=color138'
setw -g window-status-format ' #[fg=black]#W#[fg=black] '
setw -g window-status-bell-style 'fg=black bg=white bold'
# Selection style.
set -g mode-style 'fg=black,bg=yellow bold'
# Update environment from client.
set-option -g update-environment "SSH_CLIENT SSH_TTY DOCKER_CONFIG DOCKER_HOST DISPLAY XAUTHORITY"

4
.gitignore vendored
View file

@ -66,10 +66,6 @@
!/.config/bash/
!/.config/bash/**
# Tmux config.
!/.config/tmux/
!/.config/tmux/**
# Docker config.
!/.config/docker/
!/.config/docker/**

View file

@ -1,2 +0,0 @@
[Environment]
DRI_PRIME=1

View file

@ -1,7 +0,0 @@
[Context]
filesystems=/storage/cold_2/media/game/:ro;~/.config/MangoHud:ro;~/media/bottle;/storage/hot/media/bottle;~/download:ro;/storage/hot/media/save;~/media/save
[Environment]
MANGOHUD=1
MANGOHUD_CONFIGFILE=/home/voronind/.config/MangoHud/MangoHud.conf
DRI_PRIME=1

View file

@ -1,9 +0,0 @@
[Context]
devices=shm;kvm;dri
features=canbus
filesystems=!xdg-music;!xdg-pictures;!xdg-run/app/com.discordapp.Discord;/storage/hot/media/save;~/.config/MangoHud:ro;/storage/hot/media/steam;/storage/cold_2/media/steam
[Environment]
MANGOHUD_CONFIGFILE=/home/voronind/.config/MangoHud/MangoHud.conf
MANGOHUD=1
DRI_PRIME=1

View file

@ -1,2 +0,0 @@
[Context]
filesystems=xdg-config/gtk-3.0:ro;xdg-config/gtk-4.0:ro;

View file

@ -1,2 +0,0 @@
[Environment]
DRI_PRIME=1

View file

@ -1,6 +0,0 @@
[Context]
devices=all;shm;kvm
filesystems=home;host-etc;host-os
[Environment]
DRI_PRIME=1

View file

@ -1,2 +0,0 @@
[Environment]
DRI_PRIME=1

View file

@ -1,2 +0,0 @@
[Context]
filesystems=~/.thunderbird

View file

@ -1,3 +0,0 @@
[Context]
devices=dri
filesystems=!xdg-download;~/.config/firefox:ro;~/download;~/.mozilla