diff --git a/modules/programs/sesh.nix b/modules/programs/sesh.nix index 1b7b961e7..76791209b 100644 --- a/modules/programs/sesh.nix +++ b/modules/programs/sesh.nix @@ -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} + )\"" + ''; + }) + ]); }