Create prompt module

This commit is contained in:
2024-07-23 20:53:57 -07:00
parent 4a21cf05d2
commit eade86cef6
3 changed files with 14 additions and 13 deletions

View File

@@ -11,6 +11,7 @@
in {
nixosModules = {
common = import ./modules/common.nix;
prompt = import ./modules/prompt.nix;
server = import ./modules/server.nix;
};

View File

@@ -2,6 +2,7 @@
{
imports = [
self.nixosModules.common
self.nixosModules.prompt
./backup.nix
];
@@ -80,19 +81,6 @@
obsidian
];
programs.bash = {
promptInit = ''
PS1="\[\e]0;\u@\h: \w\a\]" # window title
PS1+="\n"
PS1+="\$(printf \"%*s\" \$((\$COLUMNS + 9)) \"\[\e[1;33m\]\$(git branch --show-current 2>/dev/null)\")" # git branch
PS1+="\[\e[1G\]" # move cursor to beginning of line
PS1+="💜" # prompt symbol
PS1+="\[\033[1;$((UID ? 32 : 31))m\]" # prompt color
PS1+="[\u@\h:\w]\\$"
PS1+="\[\033[0m\] " # reset color
'';
};
programs.steam = {
enable = true;
remotePlay.openFirewall = true;
@@ -120,6 +108,8 @@
enable = true;
};
promptEmoji = "💜";
time.timeZone = "America/Los_Angeles";
system.stateVersion = "24.05";

10
modules/prompt.nix Normal file
View File

@@ -0,0 +1,10 @@
{ options, lib, config, ... }:
{
options.promptEmoji = lib.mkOption {
type = lib.types.str;
};
config.programs.bash.promptInit = ''
PS1="\[\e]0;\u@\h: \w\a\]\n${config.promptEmoji} \[\033[1;$((UID ? 32 : 31))m\]\w \\$\[\033[0m\] "
'';
}