Z shell

Zshis a shell designed for interactive use, although it is also a powerful scripting language. Many of the useful features ofbash,ksh, andtcshwere incorporated into zsh; many original features were added.

Zsh Completion



Share My .zshrc (Refer to Kardinal) here and welcome share your experience.


RPROMPT = ' %{[33m%}(%/)'
autoload colors
colors

PROMPT = '%{[31m%}%
>>'

export EDITOR =emacs


#关于历史纪录的配置
# number of lines kept in history
export HISTSIZE =10000
# # number of lines saved in the history after logout
export SAVEHIST =10000
# # location of history
export HISTFILE =~/.zhistory
# # append command to history file once executed
setopt INC_APPEND_HISTORY

#Disable core dumps
limit coredumpsize 0

#Emacs风格键绑定
bindkey -e
#设置DEL键为向后删除
bindkey "\e[3~" delete-char

#以下字符视为单词的一部分
WORDCHARS = '*?_-[]~=&;!#$%^(){}<>'

#自动补全功能
setopt AUTO_LIST
setopt AUTO_MENU
setopt MENU_COMPLETE

autoload -U compinit
compinit

# Completion caching
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path .zcache
#zstyle ':completion:*:cd:*' ignore-parents parent pwd

#Completion Options
zstyle ':completion:*:match:*' original only
zstyle ':completion::prefix-1:*' completer _complete
zstyle ':completion:predict:*' completer _complete
zstyle ':completion:incremental:*' completer _complete _correct
zstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate

# Path Expansion
zstyle ':completion:*' expand 'yes'
zstyle ':completion:*' squeeze-shlashes 'yes'
zstyle ':completion::complete:*' '\\'

zstyle ':completion:*:*:*:default' menu yes select
zstyle ':completion:*:*:default' force-list always

# GNU Colors 需要/etc/DIR_COLORS文件 否则自动补全时候选菜单中的选项不能彩色显示
[ -f /etc/DIR_COLORS ] && eval $(dircolors -b /etc/DIR_COLORS)
export ZLSCOLORS = "${LS_COLORS}"
zmodload zsh/complist
zstyle ':completion:*' list-colors ${ (s.:.)LS_COLORS }
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'

zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric

compdef pkill = kill
compdef pkill =killall
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:processes' command 'ps -au$USER'

# Group matches and Describe
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m'
zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m'
zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m'

#命令别名
alias cp = 'cp -i'
alias mv = 'mv -i'
alias rm = 'rm -i'
alias ls = 'ls -F --color=auto'
alias ll = 'ls -l'
alias grep = 'grep --color=auto'
alias ee = 'emacsclient -t'

#路径别名 进入相应的路径时只要 cd ~xxx
hash -d WWW = "/home/lighttpd/html"
hash -d ARCH = "/mnt/arch"
hash -d PKG = "/var/cache/pacman/pkg"
hash -d E = "/etc/env.d"
hash -d C = "/etc/conf.d"
hash -d I = "/etc/rc.d"
hash -d X = "/etc/X11"
hash -d BK = "/home/r00t/config_bak"

##for Emacs在Emacs终端中使用Zsh的一些设置 不推荐在Emacs中使用它
if [[ "$TERM" == "dumb" ]]; then
setopt No_zle
PROMPT = '%n@%M %/
>>'
alias ls = 'ls -F'
fi




#效果超炫的提示符,如需要禁用,注释下面配置
functionprecmd {

localTERMWIDTH
(( TERMWIDTH = ${ COLUMNS } - 1 ))


###
# Truncate the path if it's too long.

PR_FILLBAR = ""
PR_PWDLEN = ""

local promptsize = ${#${ (%) :- --(%n@%m:%l)---()-- }}
local pwdsize = ${#${ (%) :- %~ }}

if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
(( PR_PWDLEN = $TERMWIDTH - $promptsize))
else
PR_FILLBAR = "\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
fi


###
# Get APM info.

#if which ibam > /dev/null; then
#PR_APM_RESULT=`ibam --percentbattery`
#elif which apm > /dev/null; then
#PR_APM_RESULT=`apm`
#fi
}


setopt extended_glob
preexec () {
if [[ "$TERM" == "screen" ]]; then
local CMD = ${ 1 [(wr)^(*=*|sudo|-*)] }
echo -n "\ek$CMD\e\\"
fi
}

setprompt () {
###
# Need this so the prompt will work.

setopt prompt_subst


###
# See if we can use colors.

autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
forcolor in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
evalPR_ $color = '%{$terminfo[bold]$fg[${(L)color}]%}'
evalPR_LIGHT_ $color = '%{$fg[${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOUR = "%{$terminfo[sgr0]%}"


###
# See if we can use extended characters to look nicer.

typeset -A altchar
set -A altchar ${ (s..)terminfo[acsc] }
PR_SET_CHARSET = "%{$terminfo[enacs]%}"
PR_SHIFT_IN = "%{$terminfo[smacs]%}"
PR_SHIFT_OUT = "%{$terminfo[rmacs]%}"
PR_HBAR = ${ altchar [q] :- - }
#PR_HBAR=" "
PR_ULCORNER = ${ altchar [l] :- - }
PR_LLCORNER = ${ altchar [m] :- - }
PR_LRCORNER = ${ altchar [j] :- - }
PR_URCORNER = ${ altchar [k] :- - }


###
# Decide if we need to set titlebar text.

case $TERM in
xterm*)
PR_TITLEBAR = $'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
;;
screen)
PR_TITLEBAR = $'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
;;
*)
PR_TITLEBAR = ''
;;
esac

###
# Decide whether to set a screen title
if [[ "$TERM" == "screen" ]]; then
PR_STITLE = $'%{\ekzsh\e\\%}'
else
PR_STITLE = ''
fi

###
# APM detection

#if which ibam > /dev/null; then
#PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:'
#elif which apm > /dev/null; then
#PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:'
#else
PR_APM = ''
#fi
###
# Finally, the prompt.
}
setprompt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值