Extract a tmux mixin
This commit is contained in:
parent
111c336abc
commit
3ff9d54970
10 changed files with 120 additions and 162 deletions
|
@ -6,11 +6,6 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
homeManagerModules = {
|
|
||||||
tmux.enable = true;
|
|
||||||
tmux-sessionizer.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
home =
|
home =
|
||||||
let
|
let
|
||||||
remoteIpAddress = "192.168.1.111";
|
remoteIpAddress = "192.168.1.111";
|
||||||
|
|
|
@ -1,7 +1 @@
|
||||||
{ ... }:
|
{ }
|
||||||
|
|
||||||
{
|
|
||||||
homeManagerModules = {
|
|
||||||
tmux-sessionizer.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
homeManagerModules = {
|
|
||||||
tmux.enable = true;
|
|
||||||
tmux-sessionizer.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
backup-websites
|
backup-websites
|
||||||
displayselect
|
displayselect
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
homeManagerModules = {
|
|
||||||
tmux.enable = true;
|
|
||||||
tmux-sessionizer.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
displayselect
|
displayselect
|
||||||
isync
|
isync
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
../../modules/mixins/docker.nix
|
../../modules/mixins/docker.nix
|
||||||
../../modules/mixins/fzf.nix
|
../../modules/mixins/fzf.nix
|
||||||
../../modules/mixins/phpactor
|
../../modules/mixins/phpactor
|
||||||
|
../../modules/mixins/tmux.nix
|
||||||
|
|
||||||
../common
|
../common
|
||||||
../../users/opdavies
|
../../users/opdavies
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
../../modules/mixins/pipewire.nix
|
../../modules/mixins/pipewire.nix
|
||||||
../../modules/mixins/screenkey.nix
|
../../modules/mixins/screenkey.nix
|
||||||
../../modules/mixins/thunar.nix
|
../../modules/mixins/thunar.nix
|
||||||
|
../../modules/mixins/tmux.nix
|
||||||
../../modules/profiles/dwm
|
../../modules/profiles/dwm
|
||||||
../../modules/profiles/xbanish.nix
|
../../modules/profiles/xbanish.nix
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
./bin
|
./bin
|
||||||
./git.nix
|
./git.nix
|
||||||
./starship.nix
|
./starship.nix
|
||||||
./tmux.nix
|
|
||||||
./tmux-sessionizer.nix
|
|
||||||
./zsh
|
./zsh
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
{
|
|
||||||
options.homeManagerModules.tmux-sessionizer.enable = mkEnableOption "Enable tmux-sessionizer";
|
|
||||||
|
|
||||||
config = mkIf config.homeManagerModules.tmux-sessionizer.enable {
|
|
||||||
home.packages = with pkgs; [ tmux-sessionizer ];
|
|
||||||
|
|
||||||
home.file."${config.xdg.configHome}/tmux-sessionizer/default".source = "${
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = ".tmux-sessionizer";
|
|
||||||
|
|
||||||
runtimeInputs = with pkgs; [
|
|
||||||
tmux
|
|
||||||
];
|
|
||||||
|
|
||||||
text = ''
|
|
||||||
set +o errexit
|
|
||||||
set +o nounset
|
|
||||||
|
|
||||||
if [[ "$PWD" == "$XDG_REPOS_DIR/os" || "$PWD" == "$XDG_REPOS_DIR/personal" ]]; then
|
|
||||||
clear
|
|
||||||
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmux new-window -d -n scratch
|
|
||||||
nvim .
|
|
||||||
clear
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
}/bin/.tmux-sessionizer";
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) tmuxPlugins;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.homeManagerModules.tmux.enable = mkEnableOption "Enable tmux";
|
|
||||||
|
|
||||||
config = mkIf config.homeManagerModules.tmux.enable {
|
|
||||||
programs.tmux = {
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
terminal = "tmux-256color";
|
|
||||||
|
|
||||||
extraConfig = ''
|
|
||||||
set-option -g status-keys "vi"
|
|
||||||
set-option -sa terminal-features "''${TERM}:RGB"
|
|
||||||
|
|
||||||
bind -n S-Left resize-pane -L 2
|
|
||||||
bind -n S-Right resize-pane -R 2
|
|
||||||
bind -n S-Down resize-pane -D 1
|
|
||||||
bind -n S-Up resize-pane -U 1
|
|
||||||
|
|
||||||
bind -n C-Left resize-pane -L 10
|
|
||||||
bind -n C-Right resize-pane -R 10
|
|
||||||
bind -n C-Down resize-pane -D 5
|
|
||||||
bind -n C-Up resize-pane -U 5
|
|
||||||
|
|
||||||
# Status line customisation
|
|
||||||
set-option -g status-left ""
|
|
||||||
set-option -g status-right " #{session_name}"
|
|
||||||
set-option -g status-right-length 100
|
|
||||||
set-option -g status-style "fg=#7C7D83 bg=default"
|
|
||||||
set-option -g window-status-activity-style none
|
|
||||||
set-option -g window-status-current-style "fg=#E9E9EA"
|
|
||||||
|
|
||||||
bind c new-window -c "#{pane_current_path}"
|
|
||||||
|
|
||||||
set -g base-index 1
|
|
||||||
set -g pane-base-index 1
|
|
||||||
set -g renumber-windows on
|
|
||||||
|
|
||||||
# Break a pane into a new window.
|
|
||||||
bind-key b break-pane -d
|
|
||||||
bind-key J command-prompt -p "join pane from: " "join-pane -h -s '%%'"
|
|
||||||
|
|
||||||
bind-key C-j choose-tree
|
|
||||||
|
|
||||||
set-window-option -g mode-keys vi
|
|
||||||
bind -T copy-mode-vi v send-keys -X begin-selection
|
|
||||||
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
|
|
||||||
|
|
||||||
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
|
|
||||||
|
|
||||||
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
|
|
||||||
|
|
||||||
# Allow clearing screen with ctrl-l by using <prefix> C-l
|
|
||||||
bind C-l send-keys "C-l"
|
|
||||||
bind C-k send-keys "C-k"
|
|
||||||
|
|
||||||
# Enable mouse support.
|
|
||||||
setw -g mouse on
|
|
||||||
|
|
||||||
# Remove delay when switching Vim modes.
|
|
||||||
set -sg escape-time 0
|
|
||||||
|
|
||||||
set-option -g pane-active-border-style "fg=#1f2335"
|
|
||||||
set-option -g pane-border-style "fg=#1f2335"
|
|
||||||
|
|
||||||
# Vim-like pane navigation.
|
|
||||||
bind ^ last-window
|
|
||||||
bind h select-pane -L
|
|
||||||
bind j select-pane -D
|
|
||||||
bind k select-pane -U
|
|
||||||
bind l select-pane -R
|
|
||||||
|
|
||||||
bind-key -r f run-shell "tmux new-window tmux-sessionizer"
|
|
||||||
|
|
||||||
bind-key -r D new-window -c "#{pane_current_path}" "[[ -e TODO.md ]] && nvim TODO.md || nvim ~/Documents/wiki/todo.txt"
|
|
||||||
bind-key -r N new-window "notes"
|
|
||||||
bind-key -r W split-window -h -c ~/Documents/wiki "nvim '+Telescope find_files'"
|
|
||||||
'';
|
|
||||||
|
|
||||||
plugins = [
|
|
||||||
tmuxPlugins.vim-tmux-navigator
|
|
||||||
tmuxPlugins.yank
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
117
modules/mixins/tmux.nix
Normal file
117
modules/mixins/tmux.nix
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.tmux = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
terminal = "tmux-256color";
|
||||||
|
|
||||||
|
extraConfig = ''
|
||||||
|
set-option -g status-keys "vi"
|
||||||
|
set-option -sa terminal-features "''${TERM}:RGB"
|
||||||
|
|
||||||
|
bind -n S-Left resize-pane -L 2
|
||||||
|
bind -n S-Right resize-pane -R 2
|
||||||
|
bind -n S-Down resize-pane -D 1
|
||||||
|
bind -n S-Up resize-pane -U 1
|
||||||
|
|
||||||
|
bind -n C-Left resize-pane -L 10
|
||||||
|
bind -n C-Right resize-pane -R 10
|
||||||
|
bind -n C-Down resize-pane -D 5
|
||||||
|
bind -n C-Up resize-pane -U 5
|
||||||
|
|
||||||
|
# Status line customisation
|
||||||
|
set-option -g status-left ""
|
||||||
|
set-option -g status-right " #{session_name}"
|
||||||
|
set-option -g status-right-length 100
|
||||||
|
set-option -g status-style "fg=#7C7D83 bg=default"
|
||||||
|
set-option -g window-status-activity-style none
|
||||||
|
set-option -g window-status-current-style "fg=#E9E9EA"
|
||||||
|
|
||||||
|
bind c new-window -c "#{pane_current_path}"
|
||||||
|
|
||||||
|
set -g base-index 1
|
||||||
|
set -g pane-base-index 1
|
||||||
|
set -g renumber-windows on
|
||||||
|
|
||||||
|
# Break a pane into a new window.
|
||||||
|
bind-key b break-pane -d
|
||||||
|
bind-key J command-prompt -p "join pane from: " "join-pane -h -s '%%'"
|
||||||
|
|
||||||
|
bind-key C-j choose-tree
|
||||||
|
|
||||||
|
set-window-option -g mode-keys vi
|
||||||
|
bind -T copy-mode-vi v send-keys -X begin-selection
|
||||||
|
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
|
||||||
|
|
||||||
|
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
|
||||||
|
|
||||||
|
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
|
||||||
|
|
||||||
|
# Allow clearing screen with ctrl-l by using <prefix> C-l
|
||||||
|
bind C-l send-keys "C-l"
|
||||||
|
bind C-k send-keys "C-k"
|
||||||
|
|
||||||
|
# Enable mouse support.
|
||||||
|
setw -g mouse on
|
||||||
|
|
||||||
|
# Remove delay when switching Vim modes.
|
||||||
|
set -sg escape-time 0
|
||||||
|
|
||||||
|
set-option -g pane-active-border-style "fg=#1f2335"
|
||||||
|
set-option -g pane-border-style "fg=#1f2335"
|
||||||
|
|
||||||
|
# Vim-like pane navigation.
|
||||||
|
bind ^ last-window
|
||||||
|
bind h select-pane -L
|
||||||
|
bind j select-pane -D
|
||||||
|
bind k select-pane -U
|
||||||
|
bind l select-pane -R
|
||||||
|
|
||||||
|
bind-key -r f run-shell "tmux new-window tmux-sessionizer"
|
||||||
|
|
||||||
|
bind-key -r D new-window -c "#{pane_current_path}" "[[ -e TODO.md ]] && nvim TODO.md || nvim ~/Documents/wiki/todo.txt"
|
||||||
|
bind-key -r N new-window "notes"
|
||||||
|
bind-key -r W split-window -h -c ~/Documents/wiki "nvim '+Telescope find_files'"
|
||||||
|
'';
|
||||||
|
|
||||||
|
plugins = with pkgs.tmuxPlugins; [
|
||||||
|
vim-tmux-navigator
|
||||||
|
yank
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
home-manager.users.opdavies =
|
||||||
|
{ config, ... }:
|
||||||
|
with pkgs;
|
||||||
|
{
|
||||||
|
home.packages = [
|
||||||
|
tmux-sessionizer
|
||||||
|
];
|
||||||
|
|
||||||
|
xdg.configFile."tmux-sessionizer/default".source = "${
|
||||||
|
writeShellApplication {
|
||||||
|
name = ".tmux-sessionizer";
|
||||||
|
|
||||||
|
runtimeInputs = [
|
||||||
|
tmux
|
||||||
|
];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
set +o errexit
|
||||||
|
set +o nounset
|
||||||
|
|
||||||
|
if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" ]]; then
|
||||||
|
clear
|
||||||
|
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmux new-window -d -n scratch
|
||||||
|
nvim .
|
||||||
|
clear
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
}/bin/.tmux-sessionizer";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue