Initial commit
This commit is contained in:
commit
335836dac7
2 changed files with 71 additions and 0 deletions
9
flake.nix
Normal file
9
flake.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
description = "Serval Prompt";
|
||||
|
||||
outputs =
|
||||
{ ... }:
|
||||
{
|
||||
nixosModules.default = import ./module.nix;
|
||||
};
|
||||
}
|
||||
62
module.nix
Normal file
62
module.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
mkEnableOption
|
||||
mkIf
|
||||
optionalString
|
||||
types
|
||||
getExe
|
||||
;
|
||||
inherit (pkgs) gitMinimal;
|
||||
cfg = config.programs.fish.servalPrompt;
|
||||
|
||||
in
|
||||
{
|
||||
options.programs.fish.servalPrompt = {
|
||||
enable = mkEnableOption "Serval Prompt";
|
||||
prefix = mkOption {
|
||||
type = types.str;
|
||||
description = "Prompt prefix.";
|
||||
example = "🐆";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
programs.fish = {
|
||||
promptInit = ''
|
||||
set -g fish_prompt_pwd_full_dirs 999
|
||||
|
||||
function fish_prompt
|
||||
set -l uc (fish_is_root_user && echo red || echo magenta)
|
||||
set -l cc (fish_is_root_user && echo red || echo brgreen)
|
||||
printf '%s %s%s %s%s%s > ' \
|
||||
'${cfg.prefix}' \
|
||||
(set_color $uc) $USER \
|
||||
(set_color $cc) (prompt_pwd) \
|
||||
(set_color normal)
|
||||
end
|
||||
|
||||
function fish_right_prompt
|
||||
set -l branch (${getExe gitMinimal} branch --show-current 2>/dev/null)
|
||||
and printf '%s%s' (set_color bryellow) $branch
|
||||
end
|
||||
''
|
||||
+ optionalString config.services.openssh.enable ''
|
||||
|
||||
function fish_greeting
|
||||
test -n "$SSH_CLIENT" -a $SHLVL -eq 1
|
||||
and printf 'Connected to ${cfg.prefix} %s%s%s as %s%s%s\n' \
|
||||
(set_color cyan) $hostname (set_color normal) \
|
||||
(set_color magenta) $USER (set_color normal)
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue