69 lines
1.2 KiB
Bash
69 lines
1.2 KiB
Bash
# ~/.zsh/prompt.sh
|
|
|
|
autoload -Uz vcs_info
|
|
precmd_vcs_info() { vcs_info }
|
|
precmd_functions+=( precmd_vcs_info )
|
|
setopt prompt_subst
|
|
|
|
c_dir_bg="#CD96CD"
|
|
c_dir_fg="#000000"
|
|
c_branch_bg="#A3BE8C"
|
|
c_branch_fg="#000000"
|
|
c_ok="#D7FF00"
|
|
c_no="#FF4500"
|
|
|
|
dir_empty_icon=" "
|
|
dir_filled_icon=" "
|
|
git_branch_icon=""
|
|
|
|
dir_is_empty()
|
|
{
|
|
local -a files
|
|
files=( *(N) .*(N) )
|
|
(( ${#files} == 0 ))
|
|
}
|
|
|
|
get_prompt_dir()
|
|
{
|
|
local dir icon tail
|
|
|
|
icon=" "
|
|
tail="%F{${c_dir_bg}}%f"
|
|
|
|
if [[ -n ${vcs_info_msg_0_} ]]; then
|
|
tail="%F{${c_dir_bg}}%K{${c_branch_bg}}%k%f"
|
|
fi
|
|
|
|
if [[ -z $(ls -A . 2>/dev/null) ]]; then
|
|
icon=" "
|
|
fi
|
|
|
|
dir="%f%K{${c_dir_bg}}%F{${c_dir_fg}} ${icon} %~ %f%k${tail}"
|
|
print -r -- "$dir"
|
|
}
|
|
|
|
get_prompt_branch()
|
|
{
|
|
local branch
|
|
|
|
if [[ -n ${vcs_info_msg_0_} ]]; then
|
|
branch="%F{${c_branch_fg}}%K{${c_branch_bg}} ${vcs_info_msg_0_} %k%f%F{${c_branch_bg}}%f"
|
|
else
|
|
branch=""
|
|
fi
|
|
|
|
print -r -- "$branch"
|
|
}
|
|
|
|
result="%(?..%F{${c_no}} %f)"
|
|
|
|
if [[ "$TERM" == "linux" ]]; then
|
|
# Simple ASCII prompt for TTY
|
|
PROMPT='%n@%m %~ %# '
|
|
else
|
|
PROMPT='$(get_prompt_dir)$(get_prompt_branch)${result}
|
|
%B%F{#D7FF00}%f%b '
|
|
fi
|
|
|
|
zstyle ':vcs_info:git:*' formats '%b'
|