-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
108 lines (89 loc) · 2.66 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
# history
echo "Setting up ZSH features"
HISTFILE=~/.zsh_history
HISTSIZE=5000
SAVEHIST=1000
setopt appendhistory autocd extendedglob
# default apps
(( ${+BROWSER} )) || export BROWSER="w3m"
(( ${+PAGER} )) || export PAGER="less"
# prompt (if running screen, show window #)
if [ x$WINDOW != x ]; then
export PS1="$WINDOW:%~%# "
else
export PS1='%~ %# '
fi
# format titles for screen and rxvt
function title() {
# escape '%' chars in $1, make nonprintables visible
a=${(V)1//\%/\%\%}
# Truncate command, and join lines.
a=$(print -Pn "%40>...>$a" | tr -d "\n")
case $TERM in
screen)
print -Pn "\ek$a:$3\e\\" # screen title (in ^A")
;;
xterm*|rxvt)
print -Pn "\e]2;$2 | $a:$3\a" # plain xterm title
;;
esac
}
# precmd is called just before the prompt is printed
function precmd() {
title "zsh" "$USER@%m" "%55<...<%~"
}
# preexec is called just before any command line is executed
function preexec() {
title "$1" "$USER@%m" "%35<...<%~"
}
# vi editing
bindkey -v
bindkey -M viins '^?' backward-delete-char
bindkey -M viins '^H' backward-delete-char
setopt AUTO_PUSHD
export LS_COLORS="no=00:fi=00:di=01;94:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:*.cfg=01;33:*.cc=92:*.h=95:*.py=96:*.root=95:"
# colorful listings
#alias ls="ls --color=auto"
zmodload -i zsh/complist
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
autoload -U compinit
compinit
# aliases
alias mv='nocorrect mv' # no spelling correction on mv
alias cp='nocorrect cp'
alias mkdir='nocorrect mkdir'
alias j=jobs
#if ls -F --color=auto >&/dev/null; then
# alias ls="ls --color=auto -F"
#else
# alias ls="ls -F"
#fi
#alias ls="ls -G"
alias ll="ls -l"
alias l.='ls -d .[^.]*'
alias lsd='ls -ld *(-/DN)'
alias md='mkdir -p'
alias rd='rmdir'
alias cd..='cd ..'
alias ..='cd ..'
alias po='popd'
alias pu='pushd'
alias tsl="tail -f /var/log/syslog"
alias df="df -hT"
# functions
mdc() { mkdir -p "$1" && cd "$1" }
setenv() { export $1=$2 } # csh compatibility
sdate() { date +%Y.%m.%d }
pc() { awk "{print \$$1}" }
rot13 () { tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" }
# shuffle input lines. Nice for mp3 playlists etc...
shuffle() {
RANDOM=`date +%s`
(
while IFS= read -r i; do
echo $RANDOM$RANDOM "$i";
done
) | sort | sed 's/^[0-9]* //'
}
export EDITOR=vim
#source ~/.zprofile