From 5b69c9bdc3e12a2af7bbc6dbd88af6004a031541 Mon Sep 17 00:00:00 2001 From: Baerspektivo Date: Wed, 30 Oct 2024 12:37:58 +0100 Subject: [PATCH] set own theme --- .zsh/aliases.zsh | 1 + .zsh/ssh.zsh | 1 + .zsh/theme.zsh | 8 ++ .zsh/theme/functions/environment.zsh | 20 ++++ .zsh/theme/functions/git.zsh | 11 +++ .zsh/theme/functions/hg.zsh | 10 ++ .zsh/theme/functions/kubernetes.zsh | 9 ++ .zsh/theme/prompts/main.zsh | 41 +++++++++ starship.toml | 133 +++++++++++++++++++++++++++ 9 files changed, 234 insertions(+) create mode 100644 .zsh/theme.zsh create mode 100644 .zsh/theme/functions/environment.zsh create mode 100644 .zsh/theme/functions/git.zsh create mode 100644 .zsh/theme/functions/hg.zsh create mode 100644 .zsh/theme/functions/kubernetes.zsh create mode 100644 .zsh/theme/prompts/main.zsh create mode 100644 starship.toml diff --git a/.zsh/aliases.zsh b/.zsh/aliases.zsh index af57b93..e4be2e4 100644 --- a/.zsh/aliases.zsh +++ b/.zsh/aliases.zsh @@ -7,6 +7,7 @@ alias kubi="open -a 'Lens'" # ALIAS COMMANDS +alias ssh="enhanced_ssh" alias ld="ls -lisaGh" alias g="goto" alias grep='grep --color' diff --git a/.zsh/ssh.zsh b/.zsh/ssh.zsh index a2ba90f..33e193b 100644 --- a/.zsh/ssh.zsh +++ b/.zsh/ssh.zsh @@ -7,3 +7,4 @@ unset SSH_AGENT_PID if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" fi + diff --git a/.zsh/theme.zsh b/.zsh/theme.zsh new file mode 100644 index 0000000..b05b1c6 --- /dev/null +++ b/.zsh/theme.zsh @@ -0,0 +1,8 @@ +# Basis-Einstellungen für das Theme +autoload -Uz colors && colors +setopt PROMPT_SUBST + +# Lade alle Theme-Komponenten +for theme_component (~/.zsh/theme/**/*.zsh); do + source $theme_component +done diff --git a/.zsh/theme/functions/environment.zsh b/.zsh/theme/functions/environment.zsh new file mode 100644 index 0000000..0cbae21 --- /dev/null +++ b/.zsh/theme/functions/environment.zsh @@ -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 +} diff --git a/.zsh/theme/functions/git.zsh b/.zsh/theme/functions/git.zsh new file mode 100644 index 0000000..e669764 --- /dev/null +++ b/.zsh/theme/functions/git.zsh @@ -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 +} diff --git a/.zsh/theme/functions/hg.zsh b/.zsh/theme/functions/hg.zsh new file mode 100644 index 0000000..ae4c75d --- /dev/null +++ b/.zsh/theme/functions/hg.zsh @@ -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 +} diff --git a/.zsh/theme/functions/kubernetes.zsh b/.zsh/theme/functions/kubernetes.zsh new file mode 100644 index 0000000..1fde615 --- /dev/null +++ b/.zsh/theme/functions/kubernetes.zsh @@ -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 +} diff --git a/.zsh/theme/prompts/main.zsh b/.zsh/theme/prompts/main.zsh new file mode 100644 index 0000000..ce6eb2e --- /dev/null +++ b/.zsh/theme/prompts/main.zsh @@ -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) diff --git a/starship.toml b/starship.toml new file mode 100644 index 0000000..b27e839 --- /dev/null +++ b/starship.toml @@ -0,0 +1,133 @@ +[aws] +symbol = " " + +[buf] +symbol = " " + +[c] +symbol = " " + +[conda] +symbol = " " + +[dart] +symbol = " " + +[directory] +read_only = " " + +[docker_context] +symbol = " " + +[elixir] +symbol = " " + +[elm] +symbol = " " + +[fossil_branch] +symbol = " " + +[git_branch] +symbol = " " + +[golang] +symbol = " " + +[guix_shell] +symbol = " " + +[haskell] +symbol = " " + +[haxe] +symbol = "⌘ " + +[hg_branch] +symbol = " " + +[java] +symbol = " " + +[julia] +symbol = " " + +[lua] +symbol = " " + +[memory_usage] +symbol = " " + +[meson] +symbol = "喝 " + +[nim] +symbol = " " + +[nix_shell] +symbol = " " + +[nodejs] +symbol = " " + +[os.symbols] +Alpine = " " +Amazon = " " +Android = " " +Arch = " " +CentOS = " " +Debian = " " +DragonFly = " " +Emscripten = " " +EndeavourOS = " " +Fedora = " " +FreeBSD = " " +Garuda = "﯑ " +Gentoo = " " +HardenedBSD = "ﲊ " +Illumos = " " +Linux = " " +Macos = " " +Manjaro = " " +Mariner = " " +MidnightBSD = " " +Mint = " " +NetBSD = " " +NixOS = " " +OpenBSD = " " +openSUSE = " " +OracleLinux = " " +Pop = " " +Raspbian = " " +Redhat = " " +RedHatEnterprise = " " +Redox = " " +Solus = "ﴱ " +SUSE = " " +Ubuntu = " " +Unknown = " " +Windows = " " + +[package] +symbol = " " + +[pijul_channel] +symbol = "🪺 " + +[python] +symbol = " " + +[rlang] +symbol = "ﳒ " + +[ruby] +symbol = " " + +[rust] +symbol = " " + +[scala] +symbol = " " + +[spack] +symbol = "🅢 "