-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
120 lines (100 loc) · 3 KB
/
zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -*- Shell-script -*-
if [[ $TERM == "dumb" ]]; then
# Fancy prompts and line editing isn't necessary on a dumb terminal, and it
# seems to confuse emacs's tramp-mode. Just turn off zle and bail early.
unsetopt zle
return
fi
# setup the prompt
setopt prompt_subst
precmd () {
[ -w "$(pwd)" ] && typeset is_cwd_writeable=true
psvar=("$SSH_CLIENT" "$is_cwd_writeable")
}
_err='%(?..%F{red}[%?]%f)'
_user='%(g.%F{red}.%F{green})%n%f'
_host='%1(V.%B.)%F{green}@%m%f%1(V.%b.) '
_jobs='%1(j.%F{yellow}(%j)%f .)'
_cwd='%2(V.%F{blue}.%F{red})%$((COLUMNS/4))<...<%~%f '
_prompt='%F{blue}%#%f '
PROMPT="${_err}${_user}${_host}${_jobs}${_trunc}${_cwd}${_prompt}"
PROMPT2='%_%F{8}>%f '
RPROMPT='%F{0}# %F{8}%D{%Y-%m-%d %H:%M:%S}%f'
unset _err _user _host _jobs _trunc _cwd _prompt
# update window titles
chpwd() {
[ -t 1 ] || return
case $TERM in
xterm*|rxvt*|screen*|st*) print -Pn "\e]2;%~ ($TERM)\a";;
esac
}
# call this now, since it doesn't happen on start up
chpwd
# set up completion
autoload -U compinit
compinit
setopt complete_aliases
setopt no_auto_menu
zstyle ':completion:*:descriptions' format '%B%U%F{8}%d%f%b%u'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-prompt ''
# configure history
export HISTSIZE=10000
export SAVEHIST=HISTSIZE
export HISTFILE="$HOME/.zsh_history"
setopt inc_append_history
setopt hist_ignore_dups
setopt hist_reduce_blanks
setopt share_history
# Fix up word-based movement commands
autoload -U select-word-style
select-word-style bash
# Make directory traversal more convenient
setopt autopushd
setopt pushd_minus
setopt pushd_ignore_dups
# Comments are useful, enable them interactively
setopt interactive_comments
# disable XON/XOFF (c-s should search, not pause)
stty -ixon
# make less more friendly for non-text input
$(which lesspipe.sh &>/dev/null) && eval "$(lesspipe.sh)"
$(which lesspipe &>/dev/null) && eval "$(lesspipe)"
# Enable colors for ls, etc.
if which dircolors >/dev/null; then
[ -e ~/.dir_colors ] || dircolors -p >~/.dir_colors
eval `dircolors -b ~/.dir_colors`
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
fi
isgnu () {
[[ "$($1 --version 2>/dev/null | head)" == *GNU* ]] && return 0
return 1
}
# Alias definitions.
isgnu ls && alias ls="ls --color=auto" || alias ls="ls -G"
alias ll="ls -l"
alias la="ls -A"
alias l="ls -Al"
alias grep="grep --color=auto"
alias psu="ps -U $USER"
alias enscript="enscript -2rE"
alias lpr="lpr -h"
alias vncviewer='vncviewer -shared'
alias et="emacsclient -t"
alias ec="emacsclient -c"
alias en="emacsclient -n"
function extglob() { zsh -c "setopt extendedglob; $*" }
alias extglob="noglob \extglob"
export EDITOR="emacsclient -t -a emacs"
export VISUAL=$EDITOR
export PAGER="less"
export LESS="-FRX"
# if the right terminfo isn't installed, remove qualifiers until we
# find one that is.
while [[ "$TERM" == *-* ]]; do
tput cols &>/dev/null
[ $? -eq 3 ] && export TERM=${TERM%-*} || break
done
# we want to know our fortune
which fortune &>/dev/null && fortune
true