diff options
| author | Skladnayazebra <skladnayazebra@gmail.com> | 2025-10-12 15:11:47 +0200 |
|---|---|---|
| committer | Skladnayazebra <skladnayazebra@gmail.com> | 2025-10-12 15:11:47 +0200 |
| commit | ed47d3f0da1581d3df04d2e506abbbf3686085e9 (patch) | |
| tree | fe54a12dc573980cfd190f096c58de7908b02015 /zsh/prompt.zsh | |
| parent | e207122a6487ea7b8a57b6f065397490cfdfd370 (diff) | |
zsh config
Diffstat (limited to 'zsh/prompt.zsh')
| -rw-r--r-- | zsh/prompt.zsh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh new file mode 100644 index 0000000..774f5f0 --- /dev/null +++ b/zsh/prompt.zsh @@ -0,0 +1,53 @@ + +# init prompts +# my fancy prompt +autoload -Uz promptinit +promptinit + +autoload -Uz vcs_info + +setopt PROMPT_SUBST + +GIT_INFO="" + +zstyle ':vcs_info:git*' formats " %b %c%u%m%a" +zstyle ':vcs_info:*' enable git +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' stagedstr ' %K{green} ✚ %k' +zstyle ':vcs_info:*' unstagedstr ' %K{red} ● %k' + +PS_GIT_TAGS="" +PS_NODE="" + +PS_ERR="%0(?..%K{red}(%?%)%k)"; +PS_GIT='%K{blue}$vcs_info_msg_0_%k' +PS_USER='%K{blue}[%n@%M] %k' +PS_DIR='%K{green} %1~ %k' + + +get_pkg_manager() { + if [[ -f yarn.lock ]]; then + echo " " + elif [[ -f pnpm-lock.yaml ]]; then + echo " " + elif [[ -f package-lock.json ]]; then + echo " " + else + echo "" + fi +} + +precmd() { + vcs_info + + PS_NODE="$(get_pkg_manager)" + git_tag=$(git describe --tags HEAD 2>/dev/null) + + if [[ $git_tag ]]; then + PS_GIT_TAGS="%K{black} $git_tag %k" + else + PS_GIT_TAGS="" + fi + + PROMPT="%B$PS_ERR$PS_DIR$PS_GIT$PS_GIT_TAGS$PS_NODE %# %b" +} |
