1
0
Files
nix-shared/system/default/prompt.nix

66 lines
2.0 KiB
Nix

{ config, pkgs, ... }:
let
# Define color codes
colors = {
deepSkyBlue = "38;5;39";
green = "38;5;70";
orange = "38;5;208";
purple = "38;5;135";
yellow = "38;5;226";
cyan = "38;5;51";
magenta = "38;5;201";
lightGreen = "38;5;118";
turquoise = "38;5;45";
purpleBlue = "38;5;99";
gold = "38;5;214";
limeGreen = "38;5;155";
lavender = "38;5;141";
teal = "38;5;80";
goldenYellow = "38;5;220";
lightPurple = "38;5;147";
};
# Static hostname to color mapping
hostnameColors = {
"ubi" = colors.deepSkyBlue; # Distinct blue
"teb" = colors.green; # Green
"wg1" = colors.orange; # Orange
"t1" = colors.purple; # Purple
"oc1" = colors.cyan; # Cyan
"tr1" = colors.magenta; # Magenta (distinct from tr2/tr3)
"tr2" = colors.lightGreen; # Light green (different from tr1)
"tr3" = colors.gold; # Gold (very different from tr1/tr2)
"rp1" = colors.turquoise; # Turquoise
"mab" = colors.lavender; # Lavender
"C02CLC7FLVDL" = colors.gold; # Gold
"M04MN219CK" = colors.gold; # Gold
};
# Get the current hostname
currentHostname = config.networking.hostName;
# Get the color for current hostname, default to teal if not in map
hostnameColor = hostnameColors.${currentHostname} or colors.teal;
# The prompt script
promptScript = ''
# Set prompt with static color: ${hostnameColor}
if [ "$EUID" -eq 0 ]; then
# Root prompt
PS1='\[\033[1;31m\][\[\033[0m\]\[\033[1;31m\]root\[\033[0m\]\[\033[1;31m\]@\[\033[0m\]\[\033[1;${hostnameColor}m\]\h\[\033[0m\]\[\033[1;31m\]:\[\033[0m\]\[\033[1;31m\]\w\[\033[0m\]\[\033[1;31m\]]\[\033[0m\]\[\033[1;31m\]#\[\033[0m\] '
else
# User prompt
PS1='\[\033[1;${hostnameColor}m\][\u@\h:\w]\$\[\033[0m\] '
fi
'';
in
{
# Bash prompt configuration
programs.bash = {
} // (if pkgs.stdenv.isDarwin then {
interactiveShellInit = promptScript;
} else {
promptInit = promptScript;
});
}