mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 08:39:42 -04:00
Merge branch 'main' of github.com:itme-brain/nixos
This commit is contained in:
commit
b570f1141f
1 changed files with 24 additions and 21 deletions
|
|
@ -25,6 +25,10 @@ nix_icon="\[\033[01;34m\] \[\033[00m\]"
|
||||||
check_venv() {
|
check_venv() {
|
||||||
if [ -n "$IN_NIX_SHELL" ]; then
|
if [ -n "$IN_NIX_SHELL" ]; then
|
||||||
add_icon "$nix_icon"
|
add_icon "$nix_icon"
|
||||||
|
else
|
||||||
|
remove_icon "$nix_icon"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$VIRTUAL_ENV" ]; then
|
if [ -n "$VIRTUAL_ENV" ]; then
|
||||||
add_icon "$python_icon"
|
add_icon "$python_icon"
|
||||||
else
|
else
|
||||||
|
|
@ -36,14 +40,16 @@ check_venv() {
|
||||||
else
|
else
|
||||||
remove_icon "$node_icon"
|
remove_icon "$node_icon"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
remove_icon "$nix_icon"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_git_dir() {
|
set_git_dir() {
|
||||||
if [ "$git_curr_dir" == "." ]; then
|
local superproject_root=$(git rev-parse --show-superproject-working-tree 2>/dev/null)
|
||||||
|
if [[ -n "$superproject_root" ]]; then
|
||||||
|
# If inside a submodule, display only the root of the parent and the submodule name
|
||||||
|
local submodule_name=$(basename "$git_root")
|
||||||
|
|
||||||
|
working_dir="\[\033[01;34m\] ''${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\] $git_root_dir\[\033[00m\]"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
|
@ -59,15 +65,12 @@ relative_path() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_project() {
|
check_project() {
|
||||||
local git_dir=$(git rev-parse --git-dir 2>/dev/null)
|
local git_root=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||||
|
|
||||||
if [ -n "$git_dir" ]; then
|
if [ -n "$git_root" ]; then
|
||||||
local git_branch=$(git branch --show-current 2>/dev/null)
|
local git_branch=$(git branch --show-current 2>/dev/null)
|
||||||
git_branch=''${git_branch:-$(git rev-parse --short HEAD 2>/dev/null)}
|
git_branch=''${git_branch:-$(git rev-parse --short HEAD 2>/dev/null)}
|
||||||
|
|
||||||
local git_dir=$(git rev-parse --git-dir)
|
|
||||||
local git_root=$(dirname "$(readlink -f "$git_dir")")
|
|
||||||
|
|
||||||
local git_curr_dir=$(relative_path "." "$git_root")
|
local git_curr_dir=$(relative_path "." "$git_root")
|
||||||
local git_root_dir=$(basename "$git_root")
|
local git_root_dir=$(basename "$git_root")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue