From 6ac3d1b33a20ab1cd3020e191372b5b8fcaa9713 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Tue, 14 May 2024 00:17:11 -0400 Subject: [PATCH] added optional gui checks for bash prompt --- src/system/machines/server/system.nix | 2 ++ src/user/modules/bash/config/prompt.nix | 23 ++++++++++++++++++++--- src/user/modules/bash/default.nix | 5 ++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/system/machines/server/system.nix b/src/system/machines/server/system.nix index d51a636..39b03c0 100644 --- a/src/system/machines/server/system.nix +++ b/src/system/machines/server/system.nix @@ -10,11 +10,13 @@ }; }; + users.mutableUsers = false; users.users = { ${config.user.name} = { isNormalUser = true; extraGroups = config.user.groups; openssh.authorizedKeys.keys = [ "${config.user.sshKeys.key1}" ]; + initialPassword = "123"; }; }; diff --git a/src/user/modules/bash/config/prompt.nix b/src/user/modules/bash/config/prompt.nix index 138a820..060a0c9 100644 --- a/src/user/modules/bash/config/prompt.nix +++ b/src/user/modules/bash/config/prompt.nix @@ -3,6 +3,7 @@ with lib; let git = config.modules.user.git; + gui = config.modules.user.gui.sway; in '' @@ -26,9 +27,15 @@ remove_icon() { venv_icons=''${venv_icons//$icon/} } +${if gui.enable then '' python_icon="\[\033[01;33m\]\[\033[00m\]" node_icon="\[\033[01;93m\]󰌞\[\033[00m\]" nix_icon="\[\033[01;34m\]\[\033[00m\]" +'' else '' +python_icon="\[\033[01;33m\]venv\[\033[00m\]" +node_icon="\[\033[01;93m\]js\[\033[00m\]" +nix_icon="\[\033[01;34m\]nix[\033[00m\]" +''} check_venv() { if [ -n "$IN_NIX_SHELL" ]; then @@ -50,17 +57,23 @@ check_venv() { fi } +${if gui.enable then '' +project_icon="" +'' else '' +project_icon="\[\033[01;34m\]git>[\033[00m\]" + +''} set_git_dir() { local superproject_root=$(git rev-parse --show-superproject-working-tree 2>/dev/null) if [[ -n "$superproject_root" ]]; then local submodule_name=$(basename "$git_root") - working_dir="\[\033[01;34m\] ''${superproject_root##*/}/$submodule_name$git_curr_dir\[\033[00m\]" + working_dir="\[\033[01;34m\]$project_icon ''${superproject_root##*/}/$submodule_name$git_curr_dir\[\033[00m\]" elif [ "$git_curr_dir" == "." ]; then - working_dir="\[\033[01;34m\] $git_root_dir\[\033[00m\]" + working_dir="\[\033[01;34m\]$project_icon $git_root_dir\[\033[00m\]" return 0 else - working_dir="\[\033[01;34m\] $git_root_dir$git_curr_dir\[\033[00m\]" + working_dir="\[\033[01;34m\]$project_icon $git_root_dir$git_curr_dir\[\033[00m\]" return 0 fi } @@ -81,7 +94,11 @@ check_project() { local git_curr_dir=$(relative_path "." "$git_root") local git_root_dir=$(basename "$git_root") + ${if gui.enable then '' git_branch_PS1="\[\033[01;31m\]$git_branch 󰘬:\[\033[00m\]" + '' else '' + git_branch_PS1="\[\033[01;31m\]$git_branch ~:\[\033[00m\]" + ''} set_git_dir check_venv diff --git a/src/user/modules/bash/default.nix b/src/user/modules/bash/default.nix index ec42b57..c27dba7 100644 --- a/src/user/modules/bash/default.nix +++ b/src/user/modules/bash/default.nix @@ -3,6 +3,7 @@ with lib; let cfg = config.modules.user.bash; + gui = config.modules.user.gui.sway; in { options.modules.user.bash = { enable = mkEnableOption "user.bash"; }; @@ -18,9 +19,11 @@ in programs = { ripgrep.enable = true; - lsd = { + eza = { enable = true; enableAliases = true; + } // optionalAttrs gui.enable { + icons = true; }; }; };