zshrc: Fix compatibility with zsh 4
This commit is contained in:
parent
7b1286f2f0
commit
2c5bc25b3e
1 changed files with 32 additions and 14 deletions
46
zshrc
46
zshrc
|
@ -5,7 +5,7 @@ export EDITOR="vim"
|
||||||
export VIMINIT="source $XDG_CONFIG_HOME/vim/vimrc"
|
export VIMINIT="source $XDG_CONFIG_HOME/vim/vimrc"
|
||||||
export PAGER="less"
|
export PAGER="less"
|
||||||
export LS_COLORS='di=34:ow=44;37:tw=44;37:st=44;37:ex=31:su=7;31:sg=7;31:ln=33:or=7;33:pi=32:do=32:bd=35:cd=35:so=32:*.bz2=36:*.dmg=36:*.gz=36:*.gpg=36:*.rar=36:*.tar=36:*.tbz2=36:*.tgz=36:*.xz=36:*.zip=36:*.orig=90:*~=90'
|
export LS_COLORS='di=34:ow=44;37:tw=44;37:st=44;37:ex=31:su=7;31:sg=7;31:ln=33:or=7;33:pi=32:do=32:bd=35:cd=35:so=32:*.bz2=36:*.dmg=36:*.gz=36:*.gpg=36:*.rar=36:*.tar=36:*.tbz2=36:*.tgz=36:*.xz=36:*.zip=36:*.orig=90:*~=90'
|
||||||
export SUDO_PROMPT=$(printf "\033[0;31m[\033[1;31msudo -> %%U\033[0;31m]\033[0m Password for \033[1m%%p@%%H\033[0m: ")
|
export SUDO_PROMPT="$(printf "\033[0;31m[\033[1;31msudo -> %%U\033[0;31m]\033[0m Password for \033[1m%%p@%%H\033[0m: ")"
|
||||||
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
|
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
|
||||||
export CVS_RSH="ssh"
|
export CVS_RSH="ssh"
|
||||||
LISTMAX=32768
|
LISTMAX=32768
|
||||||
|
@ -18,28 +18,34 @@ local ls_on_cd="yes"
|
||||||
local ls_on_init="no"
|
local ls_on_init="no"
|
||||||
local normal_user="js"
|
local normal_user="js"
|
||||||
|
|
||||||
if [ "$COLORTERM" = "24bit" -o "$COLORTERM" = "truecolor" \
|
autoload -U is-at-least
|
||||||
|
|
||||||
|
if is-at-least 5.0.0 && [ "$COLORTERM" = "24bit" -o "$COLORTERM" = "truecolor" \
|
||||||
-o "$terminfo[colors]" = 16777216 ]; then
|
-o "$terminfo[colors]" = 16777216 ]; then
|
||||||
local color_cwd="#209060"
|
local color_cwd="#209060"
|
||||||
local color_host="#176945"
|
local color_host="#176945"
|
||||||
local color_suffix="#29bc7d"
|
local color_suffix="#29bc7d"
|
||||||
local color_vcs="#43d696"
|
local color_vcs="#43d696"
|
||||||
local color_vcs_braces="#29bc7d"
|
local color_vcs_braces="#29bc7d"
|
||||||
elif [ "$terminfo[colors]" = 256 ]; then
|
local color_jobs="yellow"
|
||||||
|
local color_status="red"
|
||||||
|
elif is-at-least 5.0.0 && [ "$terminfo[colors]" = 256 ]; then
|
||||||
local color_cwd="29"
|
local color_cwd="29"
|
||||||
local color_host="23"
|
local color_host="23"
|
||||||
local color_suffix="36"
|
local color_suffix="36"
|
||||||
local color_vcs="78"
|
local color_vcs="78"
|
||||||
local color_vcs_braces="36"
|
local color_vcs_braces="36"
|
||||||
|
local color_jobs="yellow"
|
||||||
|
local color_status="red"
|
||||||
else
|
else
|
||||||
local color_cwd=2
|
local color_cwd=2
|
||||||
local color_host=6
|
local color_host=6
|
||||||
local color_suffix=2
|
local color_suffix=2
|
||||||
local color_vcs=2
|
local color_vcs=2
|
||||||
local color_vcs_braces=2
|
local color_vcs_braces=2
|
||||||
|
local color_jobs=3
|
||||||
|
local color_status=1
|
||||||
fi
|
fi
|
||||||
local color_jobs="yellow"
|
|
||||||
local color_status="red"
|
|
||||||
|
|
||||||
bindkey -v
|
bindkey -v
|
||||||
# history-incremental-search-backward is much more useful than
|
# history-incremental-search-backward is much more useful than
|
||||||
|
@ -116,21 +122,31 @@ Apple_Terminal)
|
||||||
esac
|
esac
|
||||||
|
|
||||||
set_prompt() {
|
set_prompt() {
|
||||||
|
if is-at-least 5.0.0; then
|
||||||
|
color() { printf "%%F{$1}" }
|
||||||
|
nocolor() { printf "%%f" }
|
||||||
|
else
|
||||||
|
color() { printf "%%{\033[3${1}m%%}" }
|
||||||
|
nocolor() { printf "%%{\033[0m%%}" }
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
local branch="%F{$color_vcs_braces}(%F{$color_vcs}$1"
|
local branch="$(color $color_vcs_braces)($(color $color_vcs)$1"
|
||||||
branch+="%F{$color_vcs_braces})"
|
branch+="$(color $color_vcs_braces))"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(whoami)" != "$normal_user" ]; then
|
if [ "$(whoami)" != "$normal_user" ]; then
|
||||||
local user="%n@"
|
local user="%n@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS1="%F{$color_host}$user%m %F{$color_cwd}%c$branch"
|
PS1="$(color $color_host)$user%m $(color $color_cwd)%c$branch"
|
||||||
PS1+="%F{$color_suffix}%(!.#.>)%f "
|
PS1+="$(color $color_suffix)%(!.#.>)$(nocolor) "
|
||||||
PS2="%B>%b "
|
PS2="%B>%b "
|
||||||
RPS1="%(1j.%F{$color_jobs}%B%j%b%f.)%(?..%(1j. .)"
|
RPS1="%(1j.$(color $color_jobs)%B%j%b$(nocolor).)%(?..%(1j. .)"
|
||||||
RPS1+="%F{$color_status}%B%?%b%f)"
|
RPS1+="$(color $color_status)%B%?%b$(nocolor))"
|
||||||
RPS2="%(1_.%F{black}%B(%_%)%b%f.)"
|
RPS2="%(1_.$(color black)%B(%_%)%b$(nocolor).)"
|
||||||
|
|
||||||
|
unfunction color nocolor
|
||||||
}
|
}
|
||||||
set_prompt
|
set_prompt
|
||||||
|
|
||||||
|
@ -158,7 +174,7 @@ aterm|Eterm|rxvt*|uxterm*|xterm*)
|
||||||
|
|
||||||
unset_title() {
|
unset_title() {
|
||||||
precmd() {
|
precmd() {
|
||||||
print -Pn "\e]0;%c · %m\a"
|
print -Pn "\e]0;%m:%c\a"
|
||||||
__precmd
|
__precmd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +238,9 @@ __has_command vim && alias vi=vim
|
||||||
__has_command gpg2 && alias gpg=gpg2
|
__has_command gpg2 && alias gpg=gpg2
|
||||||
|
|
||||||
if [ "$(uname -s)" = "Darwin" ]; then
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
export MAKEFLAGS="-j$(($(sysctl -n machdep.cpu.thread_count) * 2))"
|
local thread_count="$(sysctl -n machdep.cpu.thread_count 2>/dev/null)"
|
||||||
|
test -z "$thread_count" && thread_count=1
|
||||||
|
export MAKEFLAGS="-j$((thread_count * 2))"
|
||||||
elif [ "$(uname -s)" = "NetBSD" ]; then
|
elif [ "$(uname -s)" = "NetBSD" ]; then
|
||||||
export MAKEFLAGS="-j$(($(/sbin/sysctl -n hw.ncpu) * 2))"
|
export MAKEFLAGS="-j$(($(/sbin/sysctl -n hw.ncpu) * 2))"
|
||||||
elif __has_command nproc; then
|
elif __has_command nproc; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue