mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 08:39:42 -04:00
i lied
This commit is contained in:
parent
a6da05c09c
commit
bda8605c12
1 changed files with 10 additions and 11 deletions
|
|
@ -14,13 +14,12 @@ check_venv() {
|
||||||
if [ -n "$VIRTUAL_ENV" ]; then
|
if [ -n "$VIRTUAL_ENV" ]; then
|
||||||
local python_icon="\[\033[01;33m\] \[\033[00m\]"
|
local python_icon="\[\033[01;33m\] \[\033[00m\]"
|
||||||
venv_icons+="$python_icon"
|
venv_icons+="$python_icon"
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
if [ -d "''${git_root}/node_modules" ]; then
|
if [ -d "''${git_root}/node_modules" ]; then
|
||||||
local node_icon="\[\033[01;93m\] \[\033[00m\]"
|
local node_icon="\[\033[01;93m\] \[\033[00m\]"
|
||||||
venv_icons+="$node_icon"
|
venv_icons+="$node_icon"
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
unset venv_icons
|
unset venv_icons
|
||||||
|
|
@ -29,9 +28,6 @@ check_venv() {
|
||||||
}
|
}
|
||||||
|
|
||||||
set_git_dir() {
|
set_git_dir() {
|
||||||
local git_curr_dir=$(realpath --relative-to="$git_root" .)
|
|
||||||
local git_root_dir=$(basename "$git_root")
|
|
||||||
|
|
||||||
if [ "$git_curr_dir" == "." ]; then
|
if [ "$git_curr_dir" == "." ]; then
|
||||||
working_dir="\[\033[01;34m\] $git_root_dir\[\033[00m\]"
|
working_dir="\[\033[01;34m\] $git_root_dir\[\033[00m\]"
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -41,17 +37,22 @@ set_git_dir() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_git() {
|
check_in_project() {
|
||||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
local git_branch=$(git branch --show-current)
|
local git_branch=$(git branch --show-current)
|
||||||
|
local git_root=$(git rev-parse --show-toplevel)
|
||||||
|
|
||||||
|
local git_curr_dir=$(realpath --relative-to="$git_root" .)
|
||||||
|
local git_root_dir=$(basename "$git_root")
|
||||||
|
|
||||||
if [ -z "$git_branch" ]; then
|
if [ -z "$git_branch" ]; then
|
||||||
git_branch=$(git rev-parse --short HEAD)
|
git_branch=$(git rev-parse --short HEAD)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git_root=$(git rev-parse --show-toplevel)
|
|
||||||
git_branch_PS1="\[\033[01;31m\]$git_branch :\[\033[00m\]"
|
git_branch_PS1="\[\033[01;31m\]$git_branch :\[\033[00m\]"
|
||||||
|
|
||||||
set_git_dir
|
set_git_dir
|
||||||
|
check_venv
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -62,13 +63,11 @@ function set_prompt() {
|
||||||
local working_dir="\[\033[01;34m\]\w\[\033[00m\]"
|
local working_dir="\[\033[01;34m\]\w\[\033[00m\]"
|
||||||
|
|
||||||
local ssh_PS1
|
local ssh_PS1
|
||||||
local git_root
|
|
||||||
local venv_icons
|
local venv_icons
|
||||||
local git_branch_PS1
|
local git_branch_PS1
|
||||||
|
|
||||||
check_git
|
|
||||||
check_ssh
|
check_ssh
|
||||||
check_venv
|
check_in_project
|
||||||
|
|
||||||
PS1="$ssh_PS1\n$working_dir\n$venv_icons$green_arrow$git_branch_PS1$white_text"
|
PS1="$ssh_PS1\n$working_dir\n$venv_icons$green_arrow$git_branch_PS1$white_text"
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue