set own theme
This commit is contained in:
20
.zsh/theme/functions/environment.zsh
Normal file
20
.zsh/theme/functions/environment.zsh
Normal file
@@ -0,0 +1,20 @@
|
||||
function ruby_prompt_info() {
|
||||
if command -v rvm-prompt >/dev/null 2>&1; then
|
||||
local ruby_version=$(rvm-prompt i v g)
|
||||
if [[ -n "$ruby_version" ]]; then
|
||||
echo "%F{red}‹${ruby_version}›%f"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function virtualenv_prompt_info() {
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
echo "%F{green}‹${VIRTUAL_ENV:t}›%f"
|
||||
fi
|
||||
}
|
||||
|
||||
function conda_prompt_info() {
|
||||
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
|
||||
echo "%F{green}‹${CONDA_DEFAULT_ENV}›%f"
|
||||
fi
|
||||
}
|
||||
11
.zsh/theme/functions/git.zsh
Normal file
11
.zsh/theme/functions/git.zsh
Normal file
@@ -0,0 +1,11 @@
|
||||
function git_prompt_info() {
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
local ref=$(git symbolic-ref HEAD 2>/dev/null)
|
||||
local branch=${ref#refs/heads/}
|
||||
if [[ -n "$(git status --porcelain 2>/dev/null)" ]]; then
|
||||
echo "%F{yellow}‹${branch}%F{red}●%F{yellow}›%f"
|
||||
else
|
||||
echo "%F{yellow}‹${branch}›%f"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
10
.zsh/theme/functions/hg.zsh
Normal file
10
.zsh/theme/functions/hg.zsh
Normal file
@@ -0,0 +1,10 @@
|
||||
function hg_prompt_info() {
|
||||
if hg root >/dev/null 2>&1; then
|
||||
local branch=$(hg branch 2>/dev/null)
|
||||
if [[ -n "$(hg status 2>/dev/null)" ]]; then
|
||||
echo "%F{yellow}‹${branch}%F{red}●%F{yellow}›%f"
|
||||
else
|
||||
echo "%F{yellow}‹${branch}›%f"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
9
.zsh/theme/functions/kubernetes.zsh
Normal file
9
.zsh/theme/functions/kubernetes.zsh
Normal file
@@ -0,0 +1,9 @@
|
||||
function get_kubectl_context() {
|
||||
if (( $+commands[kubectl] )); then
|
||||
local context=$(kubectl config current-context 2>/dev/null)
|
||||
local namespace=$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)
|
||||
if [[ -n "$context" ]]; then
|
||||
echo "%F{blue}⎈ $context:$namespace%f"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
41
.zsh/theme/prompts/main.zsh
Normal file
41
.zsh/theme/prompts/main.zsh
Normal file
@@ -0,0 +1,41 @@
|
||||
# Neue Funktionen für die Versionsinformationen
|
||||
function get_node_version() {
|
||||
if [[ -f package.json ]]; then
|
||||
if [[ -f pnpm-lock.yaml ]]; then
|
||||
echo "%F{magenta}‹pnpm $(pnpm --version)›%f "
|
||||
elif [[ -f package-lock.json ]]; then
|
||||
echo "%F{red}‹npm $(npm --version)›%f "
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function get_deno_version() {
|
||||
if [[ -f deno.json || -f deno.jsonc ]]; then
|
||||
echo "%F{green}‹deno $(deno --version | head -n1 | cut -d' ' -f2)›%f "
|
||||
fi
|
||||
}
|
||||
|
||||
# Aktualisierte Prompt-Funktion
|
||||
function set_prompt() {
|
||||
if [[ -n "$SSH_CONNECTION" ]]; then
|
||||
local user_host="%B%F{yellow}server%f%b"
|
||||
else
|
||||
local user_host="%B%F{green}local%f%b"
|
||||
fi
|
||||
local user_symbol='%(!.#.$)'
|
||||
local current_dir="%B%F{blue}%~%f%b "
|
||||
|
||||
local conda_info=$(conda_prompt_info)
|
||||
local vcs_info="$(git_prompt_info)"
|
||||
local ruby_info=$(ruby_prompt_info)
|
||||
local venv_info=$(virtualenv_prompt_info)
|
||||
local kube_info=$(get_kubectl_context)
|
||||
local node_info=$(get_node_version)
|
||||
local deno_info=$(get_deno_version)
|
||||
|
||||
PS1="▲ ${conda_info}${user_host}${current_dir}${node_info}${deno_info}${ruby_info}${vcs_info}${venv_info}${kube_info}
|
||||
△ %B${user_symbol}%b "
|
||||
|
||||
RPROMPT="%B${return_code}%b"
|
||||
}
|
||||
precmd_functions+=(set_prompt)
|
||||
Reference in New Issue
Block a user