feat(devkit): use tmux since zellij is currently broken
This commit is contained in:
75
packages/devkit/tmux/config.conf
Normal file
75
packages/devkit/tmux/config.conf
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
set -g default-terminal "screen-256color"
|
||||
set -g base-index 1
|
||||
setw -g pane-base-index 1
|
||||
|
||||
set -g status-keys vi
|
||||
set -g mode-keys vi
|
||||
|
||||
# rebind main key: C-g
|
||||
unbind C-b
|
||||
set -g prefix C-g
|
||||
bind -N "Send the prefix key through to the application" \
|
||||
C-g send-prefix
|
||||
|
||||
set -g mouse on
|
||||
setw -g aggressive-resize off
|
||||
setw -g clock-mode-style 12
|
||||
set -s escape-time 500
|
||||
set -g history-limit 2000
|
||||
|
||||
set -sg terminal-overrides ",*:RGB"
|
||||
|
||||
set -g renumber-windows on
|
||||
|
||||
# Split panes
|
||||
bind -T prefix / split-window -v -c "#{pane_current_path}"
|
||||
bind -T prefix \\ split-window -h -c "#{pane_current_path}"
|
||||
|
||||
# Panes
|
||||
bind 'h' select-pane -L # move left after prefix
|
||||
bind 'j' select-pane -D # move down after prefix
|
||||
bind 'k' select-pane -U # move up after prefix
|
||||
bind 'l' select-pane -R # move right after prefix
|
||||
|
||||
bind -n 'C-h' select-pane -L # move left
|
||||
bind -n 'C-j' select-pane -D # move down
|
||||
bind -n 'C-k' select-pane -U # move up
|
||||
bind -n 'C-l' select-pane -R # move right
|
||||
|
||||
# bind -r 'S-h' resize-pane -L 5
|
||||
# bind -r 'S-j' resize-pane -D 5
|
||||
# bind -r 'S-k' resize-pane -U 5
|
||||
# bind -r 'S-l' resize-pane -R 5
|
||||
|
||||
bind '<' swap-pane -D # swap current pane with the next one
|
||||
bind '>' swap-pane -U # swap current pane with the previous one
|
||||
|
||||
# Windows
|
||||
bind 'C-h' previous-window # select previous window
|
||||
bind 'C-l' next-window # select next window
|
||||
bind 'Tab' last-window # select last window
|
||||
|
||||
bind 'c' new-window -c "${pane_current_path}" # new window
|
||||
|
||||
|
||||
set -g @catppuccin_window_number_position "right"
|
||||
|
||||
set -g @catppuccin_window_default_fill "number"
|
||||
set -g @catppuccin_window_default_text "#W"
|
||||
|
||||
set -g @catppuccin_window_current_fill "number"
|
||||
set -g @catppuccin_window_current_text "#W"
|
||||
|
||||
set -g @catppuccin_status_modules_right "directory user host session"
|
||||
set -g @catppuccin_status_fill "icon"
|
||||
set -g @catppuccin_status_connect_separator "no"
|
||||
|
||||
set -g @catppuccin_directory_text "#{pane_current_path}"
|
||||
|
||||
set -g @resurrect-strategy-nvim 'session'
|
||||
|
||||
set-option -g mouse on
|
||||
|
||||
set -g @continuum-restore 'on'
|
||||
|
||||
80
packages/devkit/tmux/default.nix
Normal file
80
packages/devkit/tmux/default.nix
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
symlinkJoin,
|
||||
makeWrapper,
|
||||
pkgs,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
tmux ? pkgs.tmux,
|
||||
fzf ? pkgs.fzf,
|
||||
shell ? pkgs.zsh,
|
||||
}: let
|
||||
# colors = import ../colors.nix;
|
||||
sessionizer = pkgs.writeShellScriptBin "sessionizer" ''
|
||||
function tmux() { ${lib.getExe tmux} "$@"; }
|
||||
function fzf() { ${lib.getExe fzf} "$@"; }
|
||||
|
||||
${builtins.readFile ./sessionizer.sh}
|
||||
'';
|
||||
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
sensible
|
||||
|
||||
better-mouse-mode
|
||||
continuum
|
||||
resurrect
|
||||
|
||||
(catppuccin.overrideAttrs (_: {
|
||||
src = fetchFromGitHub {
|
||||
owner = "guz013";
|
||||
repo = "frappuccino-tmux";
|
||||
rev = "4255b0a769cc6f35e12595fe5a33273a247630aa";
|
||||
sha256 = "0k8yprhx5cd8v1ddpcr0dkssspc17lq2a51qniwafkkzxi3kz3i5";
|
||||
};
|
||||
}))
|
||||
];
|
||||
|
||||
cfg = pkgs.writeText "tmux.conf" ''
|
||||
${(lib.concatMapStringsSep "\n\n" (p: ''
|
||||
run-shell ${p.rtp}
|
||||
'')
|
||||
plugins)}
|
||||
|
||||
set -g default-shell "${lib.getExe shell}"
|
||||
|
||||
${builtins.readFile ./config.conf}
|
||||
|
||||
bind -T prefix g run-shell "tmux neww ${lib.getExe sessionizer}"
|
||||
'';
|
||||
|
||||
drv = symlinkJoin ({
|
||||
paths = tmux;
|
||||
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/tmux \
|
||||
--add-flags '-f' --add-flags '${cfg}'
|
||||
'';
|
||||
}
|
||||
// {inherit (tmux) name pname man meta;});
|
||||
in
|
||||
pkgs.stdenv.mkDerivation (rec {
|
||||
name = drv.name;
|
||||
pname = drv.pname;
|
||||
|
||||
buildCommand = let
|
||||
desktopEntry = pkgs.makeDesktopItem {
|
||||
name = pname;
|
||||
desktopName = name;
|
||||
exec = "${lib.getExe drv}";
|
||||
terminal = true;
|
||||
};
|
||||
in ''
|
||||
mkdir -p $out/bin
|
||||
cp ${lib.getExe drv} $out/bin
|
||||
|
||||
mkdir -p $out/share/applications
|
||||
cp ${desktopEntry}/share/applications/${pname}.desktop $out/share/applications/${pname}.desktop
|
||||
'';
|
||||
}
|
||||
// {inherit (tmux) man meta;})
|
||||
40
packages/devkit/tmux/sessionizer.sh
Normal file
40
packages/devkit/tmux/sessionizer.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
# "Chat is MIT"
|
||||
# https://github.com/ThePrimeagen/.dotfiles/blob/master/bin/.local/scripts/tmux-sessionizer
|
||||
|
||||
SEARCH_PATHS=("$HOME/.projects" "$HOME/.job" "$HOME/.work")
|
||||
|
||||
function tmux_sessionizer() {
|
||||
local paths=()
|
||||
|
||||
for p in "${SEARCH_PATHS[@]}"; do
|
||||
if [ -d "$p" ]; then
|
||||
paths+=("$p")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected="$1"
|
||||
else
|
||||
selected="$(find "${paths[@]}" -mindepth 1 -maxdepth 1 -type d | fzf)"]
|
||||
fi
|
||||
|
||||
if [[ -z "$selected" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
local selected_name="$(basename "$selected" | tr . _)"
|
||||
local tmux_running="$(pgrep tmux)"
|
||||
|
||||
if [[ -z "$TMUX" ]] && [[ -z "$tmux_running" ]]; then
|
||||
tmux new-session -s "$selected_name" -c "$selected"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! tmux has-session -t="$selected_name" 2>/dev/null; then
|
||||
tmux new-session -ds "$selected_name" -c "$selected"
|
||||
fi
|
||||
|
||||
tmux switch-client -t "$selected_name"
|
||||
}
|
||||
|
||||
tmux_sessionizer "$@"
|
||||
Reference in New Issue
Block a user