-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc
More file actions
246 lines (214 loc) · 6.46 KB
/
dot_zshrc
File metadata and controls
246 lines (214 loc) · 6.46 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# Author: Igor Zinovik <zinovik.igor@gmail.com>
# Initializing paths
cdpath=(..)
fpath=($fpath ~/.zshrc ~/.zsh/func)
path=(~/.local/bin ~/go/bin /snap/bin ~/.krew/bin ~/bin /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin)
manpath=(/usr/share/man)
# Remove duplicates from these arrays
typeset -U path cdpath fpath manpath
# Limits
# Use `limit` built-in to discover limits
limit descriptors 9000 # Max number of file descriptors
limit stacksize 8912 # Limit stack for each process in kilobytes (8MB)
limit coredumpsize 6144 # Max size of a core dump (up to 3MB)
# Use `umask -S` to print human-readble form
umask 022
# Initiating zsh options...
# autocd - change dirs in such way:
# % /usr/src, without cd
# correct - enable spell checking for input commands
# caseglob - globbing is case-sensitive
# glob - enable filename generation aka globbing
# globcomplete -
# listtypes - when listing file, show the type of each file
# ignoreeof - use "exit" to close session, not via ^D
# markdirs - append '/' to all directory names
# histignoredups - duplicates in command history are not usefull
# histignorespace - dont put spaces to command history
# pushdignoredups - dont put dups to directory stack
setopt autocd
setopt correct
setopt caseglob
setopt glob
setopt globcomplete
setopt listtypes
setopt ignoreeof
setopt markdirs
setopt histignoredups
setopt histignorespace
setopt pushdignoredups
setopt prompt_subst
setopt no__nomatch
# I dont like beeping software
unsetopt beep
# Environment varaibles setting
export XDG_DATA_HOME=$HOME/.local/share
export XDG_CONFIG_HOME=$HOME/.config
export XDG_STATE_HOME=$HOME/.local/state
export XDG_CACHE_HOME=$HOME/.cache
export BLOCKSIZE=k # 'du', 'df', 'ls -s' use this thing
export TZ=Europe/Moscow # Timezone
export HISTFILE=/dev/null # History storage
HISTSIZE=1024 # Maximum size of internal history list
SAVEHIST=1024 # Maximum amount of command history file can store
NULLCMD=cat # redirection '# <file' now works in such way:
READNULLCMD=less # 'cat file|less'
WATCHFMT='%B%n has %a at %T %l from %M' # Show place from was made last login
TIMEFMT='%E total %J' # output format for 'time' built-in
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export EDITOR=nvim
export VISUAL=nvim
export PAGER=less # PAGER for man(1) command
export LESS='-FSXirw' # Pager options
# Terminal colours
# %f - reset color settings
R='%F{red}'
M='%F{magenta}'
B='%F{blue}'
G='%F{green}'
Y='%F{yellow}'
C='%F{cyan}'
W='%F{white}'
autoload -U colors
colors
# Enable VCS plugin
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' stagedstr "($G±%f)"
zstyle ':vcs_info:*' unstagedstr "[${R}!%f]"
zstyle ':vcs_info:*' formats "%f⎇%b%u%c"
zstyle ':vcs_info:*' actionformats "%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f"
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
setopt prompt_subst
case $TERM in
xterm* | screen* )
# Execute before each prompt
precmd() {
print -Pn "\033]0;%n@%M(%y)\a" # Configuring the xterm window caption
print -Pn "\033]1;%n@%m(tty%l)\a"
vcs_info
NEWLINE=$'\n'
PROMPT="$Y($G%~$Y)%(1j.$Y{$C%j$Y}.)[$G%!$Y] ${vcs_info_msg_0_}$Y$NEWLINE%(!.$R%#.$W%%)%f "
}
# Execute just after command has been read
preexec() {
print -Pn "\033]0;%n@%M(%y)\a"
print -Pn "\033]1;%n@%m(tty%l)\a"
}
;;
esac
# Right-side prompt
#RPROMPT='[%T]'
# Spell checker prompt
SPROMPT='zsh: correct '%R' to '%r' ([Y]es/[N]o/[E]dit/[A]bort)? '
# Aliases
# N.B. no spaces around '='
# System administration and performance analysis
alias di='diff -aup'
alias dfh='df -h'
alias duh='du -h'
# Show top 5 disk space consumers
alias du5="du -h . | sort -hr| head -n 6 | sed '1 d'"
alias cpu5='ps -ax --sort=-%cpu,-%mem -o pid,%cpu,%mem,comm |head -n 6'
alias mem5="ps -ax --sort=-%mem,-%cpu -o pid,%cpu,%mem,rss,comm|head -n 6"
alias psaux='ps aux'
alias l='less -R'
alias s=ssh
alias p=ping
alias p6='ping -6'
# Kubernetes and Docker
alias d=docker
alias k=kubectl
alias kn=kubens
alias kc=kubectx
# SCM
alias g=git
# Dev tools
alias gdb='gdb -q'
alias mk=make
# Shell nifty helpers
alias ez='$EDITOR ~/.zshrc'
alias ezl='$EDITOR ~/.zshrc.local'
alias exit='cat /dev/null > ~/.zsh_history;sync;sync;clear;exit'
alias j='jobs -l' # jobs with PIDs
alias pu=pushd
alias po=popd
alias h='history -20'
alias v=nvim
# Global aliases
alias -g L='| less'
alias -g H='--help | less'
# Key-bindings
# bindkey will show all binds
bindkey -e # Enable Emacs key-bindings
bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[2~" transpose-words # Insert
bindkey "\e[3~" delete-char # Delete
bindkey "\e[4~" end-of-line # End
bindkey "\e[5~" up-line-or-hisory # PgUp
bindkey "\e[6~" down-line-or-hisory # PgDown
# Initialize zsh autocompletion module
autoload -Uz compinit
compinit
# Enabling color (GNU ls) highlightment for completion
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# Hash directories
hash -d g=~/git
hash -d dl=~/Downloads
hash -d t=~/tmp
hash -d log=/var/log
#if `which dircolors` > /dev/null; then
# eval `dircolors`
#elif [ -x `which gdircolors` ]; then
# eval `gdircolors`
#else
# LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:"
# LS_COLORS="${LS_COLORS}or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:"
# LS_COLORS="${LS_COLORS}*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:"
#fi
# OS specific settings
case `uname -s` in
Linux)
alias sc=systemctl
alias scu='systemctl --user'
alias jc='journalctl --no-hostname'
alias jcu='journalctl --no-hostname --user'
alias pstree='pstree -Gh'
alias ll='ls -FLXh -li --color=auto'
alias la='ls -FLAXh --color=auto'
alias ls='ls -FLX --color=auto'
alias yum='yum -q'
eval `dircolors -b`
;;
esac
function cpo()
{
if [ $# -le 0 ]; then
echo "usage: cpo file..."
return 1
else
for i in "$@"; do
cp $i{,.orig}
done
fi
}
function tgz()
{
if [ $# -le 0 ]; then
echo "usage: tgz dir"
return 1
fi
if [ -d "$1" ]; then
tar cf $1.tar $1
gzip $1.tar
else
echo "directory $1 does exist"
fi
}
# Variable for ~/.config/systemd/user/ssh-agent.service
#export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.sock"
# Settings specific to current host
ZSHRC_LOCAL=${HOME}/.zshrc.local
[ -r $ZSHRC_LOCAL ] && source $ZSHRC_LOCAL