Compare commits

..

No commits in common. "581d729b79327cdf19e061920dd5660b657bc395" and "7c2bf6601a66e9736a0e1513ce4bee58cd404688" have entirely different histories.

2 changed files with 37 additions and 39 deletions

View File

@ -1,22 +1,48 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) getExe;
inherit (lib) getExe getExe';
cfg = config.snowhawk.tmux.sessionizer;
tmuxCfg = config.snowhawk.tmux;
enable = cfg.enable && tmuxCfg.enable;
in
{
options.snowhawk.tmux.sessionizer = {
enable = lib.mkEnableOption "tmux-sessionizer home-manager module";
tmux-sessionizer = pkgs.writeShellApplication {
paths = lib.mkOption {
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";
runtimeInputs = with pkgs; [ tmux fzf findutils coreutils procps ];
text = ''
if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(find -L ${lib.concatStringsSep " " cfg.paths} -mindepth 1 -maxdepth 1 -type d \
| fzf --tmux center --preview="ls {} --color || true")
selected=$(find -L ${lib.concatStringsSep " " cfg.paths} -mindepth 1 -maxdepth 1 -type d | fzf)
fi
if [[ -z $selected ]]; then
@ -37,39 +63,8 @@ let
tmux switch-client -t "$selected_name"
'';
};
in
{
options.snowhawk.tmux.sessionizer = {
enable = lib.mkEnableOption "tmux-sessionizer home-manager module";
});
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}"
'';
home.packages = [ cfg.pkg ];
};
}

View File

@ -1,9 +1,10 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) getExe;
inherit (lib) getExe optionalString;
cfg = config.snowhawk.tmux;
sessionizer = cfg.sessionizer;
macos = config.snowhawk.macos.enable;
in
{
@ -40,6 +41,8 @@ in
bind '"' split-window -v -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}"
'';
};