-
Notifications
You must be signed in to change notification settings - Fork 2
/
zshrc
220 lines (192 loc) · 5.67 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/zsh
# Dircolors
eval `dircolors -b`
# Exports
export EDITOR=vim
export VISUAL=vim
export BROWSER=firefox
export OOO_FORCE_DESKTOP=gnome
export GDK_USE_XFT=1
export QT_XFT=true
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'
export PATH=".cabal-sandbox/bin:/opt/android-sdk/tools:$(which ruby && ruby -rubygems -e "puts Gem.user_dir")/bin:${HOME}/.bin:${HOME}/.cabal/bin:${PATH}"
export PYTHONDOCS=/usr/share/doc/python2/html/
export ANDROID_HOME=/opt/android-sdk
# Colors
export NC='\e[0m'
export white='\e[0;30m'
export WHITE='\e[1;30m'
export red='\e[0;31m'
export RED='\e[1;31m'
export green='\e[0;32m'
export GREEN='\e[1;32m'
export yellow='\e[0;33m'
export YELLOW='\e[1;33m'
export blue='\e[0;34m'
export BLUE='\e[1;34m'
export magenta='\e[0;35m'
export MAGENTA='\e[1;35m'
export cyan='\e[0;36m'
export CYAN='\e[1;36m'
export black='\e[0;37m'
export BLACK='\e[1;37m'
# Colorful manpages using less
export LESS_TERMCAP_mb=$'\e[1;31m'
export LESS_TERMCAP_md=$'\e[1;31m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[1;44;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;32m'
# Key bindings
bindkey "\e[1~" beginning-of-line
bindkey "\e[7~" beginning-of-line
bindkey "\e[8~" end-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[3~" delete-char
bindkey "\e[5~" beginning-of-history
bindkey "\e[6~" end-of-history
bindkey "^[[A" history-beginning-search-backward
bindkey "^[[B" history-beginning-search-forward
setopt hist_reduce_blanks
setopt hist_ignore_space
setopt append_history
setopt extended_history
setopt hist_ignore_all_dups
setopt prompt_subst
setopt no_flow_control
setopt no_case_glob
setopt numeric_glob_sort
setopt extended_glob
typeset -ga precmd_functions
typeset -ga preexec_functions
autoload -U compinit && compinit
autoload -U colors && colors
autoload -Uz vcs_info
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
zstyle ':completion:*' completer _expand _complete _approximate _ignored _match
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion:*' verbose yes
zstyle ':completion:*' menu select=2
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*:commands' rehash 1
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:kill:*:jobs' verbose yes
zstyle ':vcs_info:*' branchformat "%b"
zstyle ':vcs_info:*' actionformats "(%s/%b/%a)"
zstyle ':vcs_info:*' formats "(%s/%b)"
zstyle ':vcs_info:git:*' actionformats " %(%b/%a)"
zstyle ':vcs_info:git:*' formats "(%b)"
PROMPT='%(?..%{$fg[red]%}%? )%(#.%{$fg_bold[red]%}.%{$fg[blue]%})%n%{$fg_no_bold[default]%}@%{$fg[green]%}%m%{$fg[default]%}:%{$fg[cyan]%}%35<...<%~%(1v. %{$fg[yellow]%}%1v .)%{$fg[default]%}%(#.#.%%) '
# Really short shortcuts
alias s='sudo'
alias p='sudo pacman'
alias a='sudo aura'
alias v='vim'
alias l='lesser'
alias x='extract'
alias -g L='| less'
alias -g Q='&> /dev/null &'
# Aliases
alias sudo='sudo -E'
alias ..='cd ..'
alias ls='ls -bhp --file-type --color=auto'
alias ll='ls -l'
alias la='ls -lA'
alias mv='mv -v --backup=existing'
alias rm='rm -iv'
alias cp='cp -v'
alias grep='grep --color=auto'
alias psg='ps -ef | grep -v grep | grep '
alias lsg='la | grep '
alias mkdir='mkdir -p'
alias vless='/usr/share/vim/vim73/macros/less.sh'
alias proxy='sshuttle -r [email protected] --dns 0/0'
alias paste='fb'
alias hibernate='systemctl hibernate'
alias suspend='systemctl suspend'
alias matlab='matlab -nosplash'
# Functions
function extract() {
[[ $# != 1 ]] && echo "Usage: $0 FILE\nExtract FILE to the current directory." && return 1
[[ ! -f $1 ]] && echo "$1: Is not a valid file" && return 1
case $1 in
*.tar.gz|*.tgz)
tar xvzf $1 ;;
*.tar.bz2|*.tbz2)
tar xvjf $1 ;;
*.tar|*.gz|*.bz2|*.zip|*.rar|*.7z)
7z x $1 ;;
*)
echo "$1: No tool available to extract"
exit 1
esac
}
function mplayer() {
xautolock -disable
xset -dpms
=mplayer $@
xset +dpms
xautolock -enable
}
function lesser() {
if [[ $# == 0 ]]; then
ll .
return $?
fi
[[ $# != 1 ]] && echo "Usage: $0 PATH\nHandle PATH in a proper way" && return 1
[[ ! -e $1 ]] && echo "$1: Directory or file not found" && return 1
cmd=()
if [[ ! -r $1 ]]; then
cmd[1]="s"
fi
if [[ -f $1 ]]; then
case $1 in
*.log|*.err|*.warn|*.info)
cmd[2]="less" ;;
*)
cmd[2]="vless" ;;
esac
elif [[ -d $1 ]]; then
cmd[2]="ll"
else
echo "$1: No idea how to handle that"
return 1
fi
cmd[3]="$1"
eval ${(j: :)cmd}
}
function title() {
local access
local cmd
if [[ $USERNAME != $LOGNAME || -n $SSH_CLIENT ]]; then
access="${USERNAME}@${HOST}: "
fi
if [[ $# -eq 0 ]]; then
cmd="zsh %30<...<%~"
else
cmd="${(V)1//\%/\%\%}"
fi
case $TERM in
rxvt*)
print -Pn "\e]0;${access}${cmd}\e\\"
;;
screen*)
print -Pn "\ek${cmd}\e\\"
print -Pn "\e_${access}\e\\"
;;
esac
}
function vcs_pre() {
PSVAR=""
vcs_info
[[ -n $vcs_info_msg_0_ ]] && PSVAR[1]="$vcs_info_msg_0_"
}
precmd_functions+='title'
precmd_functions+='vcs_pre'
preexec_functions+='title'