Last active
December 16, 2024 05:41
-
-
Save carlgieringer/1df76445cc6fc1ba1edb7041e77a10d8 to your computer and use it in GitHub Desktop.
Maybe a zsh prompt (not tested much, but just so I can find the ideas again.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_branch() { | |
local branch=$(git symbolic-ref --short HEAD 2>/dev/null) | |
if [[ -n $branch ]]; then | |
echo " [${branch}]" | |
fi | |
} | |
# Function to get node version from nodenv | |
nodenv_version() { | |
if command -v nodenv >/dev/null 2>&1; then | |
local version=$(nodenv local 2>/dev/null) | |
if [[ -n $version ]]; then | |
echo " ⬢ ${version}" | |
fi | |
fi | |
} | |
# Function to get pyenv virtualenv | |
pyenv_virtualenv() { | |
if command -v pyenv >/dev/null 2>&1; then | |
local venv=$(pyenv version-name 2>/dev/null) | |
if [[ "$venv" != "system" && -n "$venv" ]]; then | |
echo " 🐍 ${venv}" | |
fi | |
fi | |
} | |
# Set up the prompt | |
setopt PROMPT_SUBST | |
# Initialize exit status indicator | |
local indicator='%(?.%F{green}●%f.%F{red}●%f)' | |
# Build the prompt | |
PROMPT='${indicator} %F{blue}%~%f$(git_branch)$(nodenv_version)$(pyenv_virtualenv) %# ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment