1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

sesh: add icons option (#6794)

Display icons next to results ({option}`--icons` argument).
This commit is contained in:
Bruno Bigras 2025-04-10 16:02:01 -04:00 committed by GitHub
parent 140a7df916
commit 8638a0b287
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -55,43 +55,57 @@ in
default = "s";
description = "Keybinding for invoking sesh in Tmux.";
};
icons = mkOption {
type = types.bool;
default = true;
description = ''
Display icons next to results ({option}`--icons` argument).
'';
};
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = [ cfg.package ];
home.file.".config/sesh/sesh.toml".source = tomlFormat.generate "sesh.toml" cfg.settings;
}
config =
let
args = lib.escapeShellArgs (lib.optional cfg.icons "--icons");
fzf-args = lib.escapeShellArgs (lib.optional cfg.icons "--ansi");
in
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.enableAlias {
home.packages = lib.mkIf (cfg.fzfPackage != null) [ cfg.fzfPackage ];
home.shellAliases.s = "sesh connect $(sesh list ${args} | fzf ${fzf-args})";
})
(mkIf cfg.enableTmuxIntegration {
assertions = [
{
assertion = config.programs.fzf.tmux.enableShellIntegration;
message = "To use Tmux integration with sesh, enable `programs.fzf.tmux.enableShellIntegration`.";
}
];
(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 ];
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)'
)\""
'';
})
]);
programs.tmux.extraConfig = ''
bind-key "${cfg.tmuxKey}" run-shell "sesh connect \"$(
sesh list ${args} | 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 ${args})' \
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list ${args} -t)' \
--bind 'ctrl-g:change-prompt( )+reload(sesh list ${args} -c)' \
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list ${args} -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 ${args})' \
-- ${fzf-args}
)\""
'';
})
]);
}