]> Sergey Matveev's repositories - dotfiles.git/blob - zsh/.zshrc
envs expansion at the end
[dotfiles.git] / zsh / .zshrc
1 # vim: foldmethod=marker:foldlevel=0
2
3 # Basic options {{{
4 setopt APPEND_HISTORY SHARE_HISTORY INC_APPEND_HISTORY HIST_IGNORE_ALL_DUPS
5 setopt HIST_IGNORE_SPACE
6 setopt INTERACTIVE_COMMENTS
7 setopt GLOB_STAR_SHORT GLOB_DOTS EXTENDED_GLOB
8 setopt NO_NOMATCH
9 setopt AUTO_PUSHD PUSHD_IGNORE_DUPS
10 # }}}
11
12 # Vi mode {{{
13 bindkey -v
14 export KEYTIMEOUT=1
15 # }}}
16
17 # Home/end {{{
18 bindkey "^[[1~" beginning-of-line
19 bindkey "^[[4~" end-of-line
20 # }}}
21
22 # Command-line editing {{{
23 autoload -U edit-command-line
24 zle -N edit-command-line
25 bindkey -M vicmd v edit-command-line
26 # }}}
27
28 # History search {{{
29 autoload -U history-search-end
30 zle -N history-beginning-search-backward-end history-search-end
31 zle -N history-beginning-search-forward-end history-search-end
32 bindkey "^[[A" history-beginning-search-backward-end
33 bindkey "^[[B" history-beginning-search-forward-end
34 bindkey "^R" history-incremental-search-backward
35 # }}}
36
37 # Prompt {{{
38 function zle-line-init zle-keymap-select {
39     mode_vi="${${KEYMAP/vicmd/+}/(main|viins)/-}"
40     [ $timer ] && timer_show=$(( $SECONDS - $timer ))
41     prompt="%2~|"
42     prompt+="%U${timer_show}%u|"
43     prompt+="%B%?%b"
44     prompt+="${mode_vi}"
45     prompt+="%F{magenta}%#%f "
46     PS1="$prompt"
47     zle reset-prompt
48 }
49 zle -N zle-line-init
50 zle -N zle-keymap-select
51
52 preexec() {
53     timer=$SECONDS
54 }
55
56 precmd() {
57     print -n "\a"
58 }
59 # }}}
60
61 # Tmux pane name {{{
62 CTP()
63 {
64     printf "\033]2;\033\\"
65 }
66 CTP
67 # }}}
68
69 # Aliases {{{
70 alias l="ls -AF "
71 alias ll="ls -AFl "
72 alias ssh="TERM=xterm ssh"
73 alias vi="vim"
74 alias more="less"
75 alias m="less "
76 alias -g M="| less"
77 alias mc="mc ; CTP"
78 bindkey -s "\eOS" " popd\n" # F4
79
80 f() {
81     # find . -name "*$1*" -print
82     print -C 1 **$1*
83 }
84
85 ssht() {
86     ssh -C -t "$1" tmux attach -t0
87 }
88 alias sshnm='ssh -o "ControlMaster no"'
89 # }}}
90
91 # Lynx {{{
92 lwe() {
93     lynx -cookies "https://en.wikipedia.org/wiki/$1"
94 }
95
96 lwr() {
97     lynx -cookies "https://ru.wikipedia.org/wiki/$1"
98 }
99 # }}}
100
101 # Git {{{
102 alias Ga="git add"
103 alias Gb="git branch"
104 alias Gc="git checkout"
105 alias Gd="git diff"
106 alias Gs="git show"
107 alias Gm="git diff --name-only --diff-filter=M"
108 alias Gam="git commit --amend"
109
110 git_common="--oneline --abbrev-commit"
111 alias Gl="git log $git_common --graph --decorate=short"
112 alias Gr="git --no-pager log $git_common -n 20 | perl -ne 'print \"@~\$n \$_\"; \$n++'"
113 alias Grr="git --no-pager log $git_common --graph -n 1024 | vi -c 'e ++enc=utf8' -"
114 alias Grpck="git gc --prune=now ; git repack -a -d --depth=4095 --window=10240"
115
116 bindkey -s "\eOQ" " git status\n" # F2
117 bindkey -s "\eOR" " git status --short\n" # F3
118 # }}}
119
120 # grep {{{
121 GREP=/usr/local/bin/grep
122 g() {
123     $GREP --color=always --with-filename --line-number --recursive $@ | less --RAW-CONTROL-CHARS
124 }
125 alias -g G="| $GREP --color"
126 alias grep="$GREP"
127 alias gg="git grep "
128 # }}}
129
130 # GPG agent {{{
131 GPG_TTY=$(tty)
132 export GPG_TTY
133 # }}}
134
135 # Virtualenv {{{
136 venv() {
137     . /usr/local/bin/virtualenvwrapper.sh
138 }
139 # }}}
140
141 # Mail {{{
142 mailpath=(
143     ~/mail/mbox"?Neue Nachrichten in =mbox"
144     ~/mail/arbeit"?Neue Nachrichten in =arbeit"
145 )
146 alias arr="mutt -f =arbeit -e 'source ~/.mutt/accounts/stcnet.ru'"
147 alias rss="mutt -f =rss"
148 bindkey -s "\eOP" " inc\n" # F1
149 # }}}
150
151 # Calculator {{{
152 autoload -U zcalc
153 alias zc="zcalc"
154 # }}}
155
156 # Paths {{{
157 export CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
158
159 export MANPATH=/usr/share/man
160 export MANPATH=/usr/local/man:$MANPATH
161 export MANPATH=/usr/local/share/man:$MANPATH
162 export MANPATH=/usr/share/openssl/man:$MANPATH
163 export MANPATH=/usr/local/lib/perl5/site_perl/man:$MANPATH
164 export MANPATH=/usr/local/lib/perl5/5.26/perl/man:$MANPATH
165
166 export PATH=$HOME/git/bin:$PATH
167 export MANPATH=$HOME/git/share/man:$MANPATH
168
169 # export PATH=$HOME/postgresql/bin:$PATH
170 # export MANPATH=$HOME/postgresql/share/man:$MANPATH
171 # [ -e ~/postgresql/lib/libpq.so.5 ] && export LD_PRELOAD=$HOME/postgresql/lib/libpq.so.5
172
173 # export PATH=$HOME/texlive/2017/bin/amd64-freebsd:$PATH
174 # export INFOPATH=/usr/local/share/info:$HOME/texlive/2017/texmf-dist/doc/info:$INFOPATH
175 # export MANPATH=$HOME/texlive/2017/texmf-dist/doc/man:$MANPATH
176
177 export PATH=$HOME/stow/bin:$PATH
178 export MANPATH=$HOME/stow/share/man:$MANPATH
179 export INFOPATH=$HOME/stow/share/info:$INFOPATH
180 # }}}
181
182 # Completion {{{
183 zstyle ":completion:*:functions" ignored-patterns "_*"
184 zstyle ":completion:*" matcher-list "" 'm:{a-z\-}={A-Z\_}' 'r:|?=** m:{a-z\-}={A-Z\_}'
185
186 _mycomp () {
187     [ $CURRENT -eq 1 ] && _command_names || _files
188 }
189 zstyle ":completion:*" completer _mycomp _parameters
190
191 autoload -U compinit ; compinit -d /tmp/.zcompdump
192
193 zstyle ":completion:*:default" list-colors ""
194 autoload -U complist
195 # }}}
196
197 # Highlighting {{{
198 ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
199 . ~/work/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
200 typeset -A ZSH_HIGHLIGHT_STYLES
201 ZSH_HIGHLIGHT_STYLES[globbing]="fg=magenta"
202 ZSH_HIGHLIGHT_STYLES[history-expansion]="fg=magenta"
203 ZSH_HIGHLIGHT_STYLES[commandseparator]="fg=red"
204 ZSH_HIGHLIGHT_STYLES[redirection]="fg=red"
205 ZSH_HIGHLIGHT_STYLES[assign]="fg=cyan"
206 # }}}
207
208 # Autosuggestion {{{
209 . ~/work/zsh-autosuggestions/zsh-autosuggestions.zsh
210 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=6"
211 # }}}
212
213 ~/bin/cleanup.sh