2022-12-26 04:59:20 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.iay;
|
2023-11-30 18:03:14 +00:00
|
|
|
inherit (lib) mkEnableOption mkIf mkOption mkPackageOption optionalString types;
|
2022-12-26 04:59:20 +00:00
|
|
|
in {
|
|
|
|
options.programs.iay = {
|
2024-04-13 13:54:15 +01:00
|
|
|
enable = mkEnableOption "iay, a minimalistic shell prompt";
|
2023-11-30 18:03:14 +00:00
|
|
|
package = mkPackageOption pkgs "iay" {};
|
2022-12-26 04:59:20 +00:00
|
|
|
|
|
|
|
minimalPrompt = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-13 13:54:15 +01:00
|
|
|
description = "Use minimal one-liner prompt.";
|
2022-12-26 04:59:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
programs.bash.promptInit = ''
|
|
|
|
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
|
|
|
PS1='$(iay ${optionalString cfg.minimalPrompt "-m"})'
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
programs.zsh.promptInit = ''
|
|
|
|
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
_iay_prompt() {
|
|
|
|
PROMPT="$(iay -z ${optionalString cfg.minimalPrompt "-m"})"
|
|
|
|
}
|
|
|
|
add-zsh-hook precmd _iay_prompt
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = pkgs.iay.meta.maintainers;
|
|
|
|
}
|