tmux-sessionizer: 2.0

This commit is contained in:
Zynh Ludwig 2024-08-23 06:26:15 -07:00
parent 7c2bf6601a
commit 9fee4f6f3d
2 changed files with 38 additions and 37 deletions

View file

@ -1,41 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
inherit (lib) getExe getExe'; inherit (lib) getExe;
cfg = config.snowhawk.tmux.sessionizer; cfg = config.snowhawk.tmux.sessionizer;
tmuxCfg = config.snowhawk.tmux; tmuxCfg = config.snowhawk.tmux;
enable = cfg.enable && tmuxCfg.enable; enable = cfg.enable && tmuxCfg.enable;
in
{
options.snowhawk.tmux.sessionizer = {
enable = lib.mkEnableOption "tmux-sessionizer home-manager module";
paths = lib.mkOption { tmux-sessionizer = pkgs.writeShellApplication {
type = with lib.types; listOf str;
description = ''
list of paths to select with tmux-sessionizer
'';
default = [ ];
example = [
"~"
"~/projects"
"~/src"
];
};
pkg = lib.mkOption {
type = lib.types.package;
description = ''
tmux-sessionizer binary package
'';
};
};
config = lib.mkIf enable {
snowhawk.tmux.sessionizer.pkg =
lib.mkDefault (pkgs.writeShellApplication {
name = "tmux-sessionizer"; name = "tmux-sessionizer";
runtimeInputs = with pkgs; [ tmux fzf findutils coreutils procps ]; runtimeInputs = with pkgs; [ tmux fzf findutils coreutils procps ];
text = '' text = ''
@ -63,8 +36,39 @@ in
tmux switch-client -t "$selected_name" tmux switch-client -t "$selected_name"
''; '';
}); };
in
{
options.snowhawk.tmux.sessionizer = {
enable = lib.mkEnableOption "tmux-sessionizer home-manager module";
home.packages = [ cfg.pkg ]; paths = lib.mkOption {
type = with lib.types; listOf str;
description = ''
list of paths to select with tmux-sessionizer
'';
default = [ ];
example = [
"~"
"~/projects"
"~/src"
];
};
package = lib.mkOption {
type = lib.types.package;
default = tmux-sessionizer;
description = ''
tmux-sessionizer binary package
'';
};
};
config = lib.mkIf enable {
home.packages = [ cfg.package ];
programs.tmux.extraConfig = ''
bind-key -r f run-shell "tmux neww ${getExe cfg.package}"
'';
}; };
} }

View file

@ -1,10 +1,9 @@
{ lib, config, pkgs, ... }: { lib, config, pkgs, ... }:
let let
inherit (lib) getExe optionalString; inherit (lib) getExe;
cfg = config.snowhawk.tmux; cfg = config.snowhawk.tmux;
sessionizer = cfg.sessionizer;
macos = config.snowhawk.macos.enable; macos = config.snowhawk.macos.enable;
in in
{ {
@ -41,8 +40,6 @@ in
bind '"' split-window -v -c "#{pane_current_path}" bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}" bind % split-window -h -c "#{pane_current_path}"
'' + optionalString sessionizer.enable ''
bind-key -r f run-shell "tmux neww ${getExe sessionizer.pkg}"
''; '';
}; };