mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 08:39:42 -04:00
prompt updatoor
This commit is contained in:
parent
e885a5427e
commit
3b68af8c91
1 changed files with 18 additions and 9 deletions
|
|
@ -6,13 +6,20 @@ check_ssh() {
|
|||
}
|
||||
|
||||
function check_venv() {
|
||||
if [ -n "''${IN_NIX_SHELL}" ]; then
|
||||
if [ -n "$VIRTUAL_ENV" ]; then
|
||||
python_icon="\[\033[01;33m\] \[\033[00m\]"
|
||||
fi
|
||||
if [ -n "$IN_NIX_SHELL" ]; then
|
||||
nix_icon="\[\033[01;34m\] \[\033[00m\]"
|
||||
venv_icons+="$nix_icon"
|
||||
|
||||
if [ -n "$VIRTUAL_ENV" ]; then
|
||||
python_icon="\[\033[01;31m\] \[\033[00m\]"
|
||||
venv_icons+="$python_icon"
|
||||
fi
|
||||
if [ -d "''${git_root}/node_modules" ]; then
|
||||
node_icon="\[\033[01;33m\] \[\033[00m\]"
|
||||
venv_icons+="$node_icon"
|
||||
fi
|
||||
else
|
||||
unset nix_icon python_icon
|
||||
unset venv_icons
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +39,7 @@ function check_git() {
|
|||
git_branch=$(git rev-parse --short HEAD)
|
||||
fi
|
||||
|
||||
local git_root=$(git rev-parse --show-toplevel)
|
||||
git_root=$(git rev-parse --show-toplevel)
|
||||
local git_root_dir=$(basename "$git_root")
|
||||
git_branch_PS1="\[\033[01;31m\]$git_branch :\[\033[00m\]"
|
||||
|
||||
|
|
@ -44,13 +51,15 @@ function set_prompt() {
|
|||
local working_dir="\[\033[01;34m\]\w\[\033[00m\]"
|
||||
local green_arrow="\[\033[01;32m\]>> "
|
||||
local white_text="\[\033[00m\]"
|
||||
local git_root
|
||||
local venv_icons
|
||||
local git_branch_PS1
|
||||
|
||||
check_git
|
||||
check_ssh
|
||||
check_venv
|
||||
check_git
|
||||
|
||||
PS1="$ssh_PS1\n$working_dir\n$nix_icon$python_icon$green_arrow$git_branch_PS1$white_text"
|
||||
unset git_branch_PS1
|
||||
PS1="$ssh_PS1\n$working_dir\n$venv_icons$green_arrow$git_branch_PS1$white_text"
|
||||
}
|
||||
|
||||
PROMPT_COMMAND="set_prompt"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue