mirror of
https://github.com/rydesun/dotfiles.git
synced 2025-12-26 14:44:58 +08:00
Update zsh prompt
This commit is contained in:
parent
e254088324
commit
02dce5da52
3 changed files with 15 additions and 9 deletions
|
|
@ -13,13 +13,14 @@
|
|||
local length=${#elements}
|
||||
for i in {1..$((length-1))}; do
|
||||
local elem=${elements[$i]}
|
||||
if [[ ${#elem} > 1 ]]; then
|
||||
if [[ $i > 2 ]] && [[ ${#elem} > 1 ]]; then
|
||||
local c=${elem:0:1}
|
||||
if [[ $c == '.' ]]; then
|
||||
elements[$i]=${elem:0:2}
|
||||
elem=${elem:0:2}
|
||||
else
|
||||
elements[$i]=${elem:0:1}
|
||||
elem=${elem:0:1}
|
||||
fi
|
||||
elements[$i]=${_PROMPT_COLOR_COLLAPSED_PWD}$elem${_PROMPT_COLOR_PWD}
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
_PROMPT_COLOR_PWD=%{$fg[magenta]%}
|
||||
_PROMPT_COLOR_COLLAPSED_PWD=%{$fg[red]%}
|
||||
_PROMPT_COLOR_GIT=%{$fg[red]%}
|
||||
_PROMPT_COLOR_SSH=%{$bg[red]$fg[black]%}
|
||||
|
||||
_theme_use_icon() {
|
||||
_PROMPT_ERR="%F{#C03C5A}▌%F{reset}"
|
||||
_PROMPT_OK="%F{#5DAC81}▌%F{reset}"
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ fi
|
|||
|
||||
# 其他
|
||||
fpath+=(${ZDOTDIR}/functions ${ZDOTDIR}/Completion)
|
||||
# function: 模仿fish折叠路径
|
||||
autoload -Uz fish_collapsed_pwd
|
||||
# 折叠路径
|
||||
autoload -Uz collapsed_pwd
|
||||
# >>>-----------------------------------
|
||||
# <<< z.lua (var)
|
||||
# 数据文件路径
|
||||
|
|
@ -116,13 +116,13 @@ precmd() {
|
|||
if command -v __git_ps1 &>/dev/null; then
|
||||
local git_status=$(__git_ps1 "%s")
|
||||
if [[ -n $git_status ]]; then
|
||||
prompt_array+=%{$fg[red]%}${git_status}%{$reset_color%}
|
||||
prompt_array+=${_PROMPT_COLOR_GIT}${git_status}%{$reset_color%}
|
||||
fi
|
||||
fi
|
||||
|
||||
# 工作目录
|
||||
if command -v fish_collapsed_pwd &>/dev/null; then
|
||||
prompt_array+=%{$fg[magenta]%}$(fish_collapsed_pwd)%{$reset_color%}
|
||||
if command -v collapsed_pwd &>/dev/null; then
|
||||
prompt_array+=${_PROMPT_COLOR_PWD}$(collapsed_pwd)%{$reset_color%}
|
||||
else
|
||||
prompt_array+=$PWD
|
||||
fi
|
||||
|
|
@ -141,7 +141,7 @@ precmd() {
|
|||
|
||||
PROMPT="$prompt_array "
|
||||
}
|
||||
((_ENV_SSH)) && RPROMPT="%{$bg[red]$fg[black]%} %n@%m %{$reset_color%}"
|
||||
((_ENV_SSH)) && RPROMPT="${_PROMPT_COLOR_SSH} %n@%m %{$reset_color%}"
|
||||
# >>>-----------------------------------
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue