mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
sesh: add module
Sesh is a CLI that helps you create and manage tmux sessions quickly and easily using zoxide. See https://github.com/joshmedeski/sesh for more.
This commit is contained in:
parent
1efd250317
commit
9e33dc24ba
8 changed files with 151 additions and 0 deletions
|
@ -732,4 +732,10 @@
|
|||
github = "Noodlez1232";
|
||||
githubId = 12480453;
|
||||
};
|
||||
michaelvanstraten = {
|
||||
name = "Michael van Straten";
|
||||
email = "michael@vanstraten.de";
|
||||
github = "michaelvanstraten";
|
||||
githubId = 50352631;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2180,6 +2180,17 @@ in {
|
|||
scrobbler (e.g. last.fm)
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2025-03-29T11:16:07+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.sesh'.
|
||||
|
||||
Sesh is a CLI that helps you create and manage tmux sessions quickly
|
||||
and easily using zoxide. See https://github.com/joshmedeski/sesh for
|
||||
more.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -237,6 +237,7 @@ let
|
|||
./programs/scmpuff.nix
|
||||
./programs/script-directory.nix
|
||||
./programs/senpai.nix
|
||||
./programs/sesh.nix
|
||||
./programs/sftpman.nix
|
||||
./programs/sioyek.nix
|
||||
./programs/skim.nix
|
||||
|
|
86
modules/programs/sesh.nix
Normal file
86
modules/programs/sesh.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkIf mkMerge mkOption mkPackageOption types;
|
||||
|
||||
cfg = config.programs.sesh;
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
in {
|
||||
meta.maintainers = [ lib.hm.maintainers.michaelvanstraten ];
|
||||
|
||||
options.programs.sesh = {
|
||||
enable = mkEnableOption "the sesh terminal session manager";
|
||||
|
||||
package = mkPackageOption pkgs "sesh" { };
|
||||
fzfPackage = mkPackageOption pkgs "fzf" { nullable = true; };
|
||||
zoxidePackage = mkPackageOption pkgs "zoxide" { nullable = true; };
|
||||
|
||||
settings = mkOption {
|
||||
type = types.submodule { freeformType = tomlFormat.type; };
|
||||
default = { };
|
||||
description = ''
|
||||
Configuration for sesh, written to `~/.config/sesh/sesh.toml`.
|
||||
|
||||
See the [sesh documentation](https://github.com/joshmedeski/sesh#configuration) for available options.
|
||||
'';
|
||||
};
|
||||
|
||||
enableAlias = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description =
|
||||
"Whether to enable a shell alias `s` to quickly launch sessions.";
|
||||
};
|
||||
|
||||
enableTmuxIntegration = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Enable Tmux integration with sesh.";
|
||||
};
|
||||
|
||||
tmuxKey = mkOption {
|
||||
type = types.str;
|
||||
default = "s";
|
||||
description = "Keybinding for invoking sesh in Tmux.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
home.packages = [ cfg.package ];
|
||||
home.file.".config/sesh/sesh.toml".source =
|
||||
tomlFormat.generate "sesh.toml" cfg.settings;
|
||||
}
|
||||
|
||||
(mkIf cfg.enableAlias {
|
||||
home.packages = lib.mkIf (cfg.fzfPackage != null) [ cfg.fzfPackage ];
|
||||
home.shellAliases.s = "sesh connect $(sesh list | fzf)";
|
||||
})
|
||||
|
||||
(mkIf cfg.enableTmuxIntegration {
|
||||
assertions = [{
|
||||
assertion = config.programs.fzf.tmux.enableShellIntegration;
|
||||
message =
|
||||
"To use Tmux integration with sesh, enable `programs.fzf.tmux.enableShellIntegration`.";
|
||||
}];
|
||||
|
||||
home.packages =
|
||||
lib.mkIf (cfg.zoxidePackage != null) [ cfg.zoxidePackage ];
|
||||
|
||||
programs.tmux.extraConfig = ''
|
||||
bind-key "${cfg.tmuxKey}" run-shell "sesh connect \"$(
|
||||
sesh list | fzf-tmux -p 55%,60% \
|
||||
--no-sort --ansi --border-label ' sesh ' --prompt '⚡ ' \
|
||||
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
|
||||
--bind 'tab:down,btab:up' \
|
||||
--bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list)' \
|
||||
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t)' \
|
||||
--bind 'ctrl-g:change-prompt(⚙️ )+reload(sesh list -c)' \
|
||||
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z)' \
|
||||
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
|
||||
--bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt(⚡ )+reload(sesh list)'
|
||||
)\""
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -386,6 +386,7 @@ in import nmtSrc {
|
|||
./modules/programs/sbt
|
||||
./modules/programs/scmpuff
|
||||
./modules/programs/senpai
|
||||
./modules/programs/sesh
|
||||
./modules/programs/sftpman
|
||||
./modules/programs/sioyek
|
||||
./modules/programs/sm64ex
|
||||
|
|
33
tests/modules/programs/sesh/basic-configuration.nix
Normal file
33
tests/modules/programs/sesh/basic-configuration.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.fzf.tmux.enableShellIntegration = true;
|
||||
|
||||
programs.sesh = {
|
||||
enable = true;
|
||||
package = pkgs.writeScriptBin "dummy-polybar" "";
|
||||
settings = {
|
||||
default_session.startup_command = "nvim -c ':Telescope find_files'";
|
||||
session = [
|
||||
{
|
||||
name = "Downloads 📥";
|
||||
path = "~/Downloads";
|
||||
startup_command = "ls";
|
||||
}
|
||||
{
|
||||
name = "tmux config";
|
||||
path = "~/c/dotfiles/.config/tmux";
|
||||
startup_command = "nvim tmux.conf";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/sesh/sesh.toml
|
||||
assertFileContent home-files/.config/sesh/sesh.toml \
|
||||
${./basic-configuration.toml}
|
||||
'';
|
||||
};
|
||||
}
|
12
tests/modules/programs/sesh/basic-configuration.toml
Normal file
12
tests/modules/programs/sesh/basic-configuration.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[default_session]
|
||||
startup_command = "nvim -c ':Telescope find_files'"
|
||||
|
||||
[[session]]
|
||||
name = "Downloads 📥"
|
||||
path = "~/Downloads"
|
||||
startup_command = "ls"
|
||||
|
||||
[[session]]
|
||||
name = "tmux config"
|
||||
path = "~/c/dotfiles/.config/tmux"
|
||||
startup_command = "nvim tmux.conf"
|
1
tests/modules/programs/sesh/default.nix
Normal file
1
tests/modules/programs/sesh/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ sesh-basic-configuration = ./basic-configuration.nix; }
|
Loading…
Add table
Reference in a new issue