diff --git a/home/zsh/default.nix b/home/zsh/default.nix index 987f3b8..2d07d9e 100644 --- a/home/zsh/default.nix +++ b/home/zsh/default.nix @@ -15,6 +15,12 @@ in enable = my.mkDisableOption "zsh configuration"; launchTmux = mkEnableOption "auto launch tmux at shell start"; + + notify = { + enable = mkEnableOption "zsh-done notification"; + + enableSsh = mkEnableOption "notify through SSH connections"; + }; }; config = lib.mkIf cfg.enable (lib.mkMerge [ @@ -93,5 +99,33 @@ in enableVteIntegration = true; }; } + + (lib.mkIf cfg.notify.enable { + home.zsh = { + plugins = [ + { + name = "zsh-done"; + file = "share/zsh/site-functions/done.plugin.zsh"; + src = pkgs.my.zsh-done; + } + ]; + + localVariables = { + # Enable `zsh-done` through SSH, if configured + DONE_ALLOW_NONGRAPHICAL = lib.mkIf cfg.notify.enableSsh 1; + }; + + # Use OSC-777 to send the notification through SSH + initExtra = lib.mkIf cfg.notify.enableSsh '' + done_send_notification() { + local exit_status="$1" + local title="$2" + local message="$3" + + ${lib.getExe pkgs.my.osc777} "$title" "$message" + } + ''; + }; + }) ]); }