]> Sergey Matveev's repositories - dotfiles.git/blob - zsh/.zshrc
gS is too hard to type quickly, because of space
[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 --nomouse ; 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 -S none'
89 # }}}
90
91 # Git {{{
92 alias Ga="git add"
93 alias Gb="git branch"
94 alias Gc="git checkout"
95 alias Gd="git diff"
96 alias Gs="git show"
97 alias Gm="git diff --name-only --diff-filter=M"
98 alias Gam="git commit --amend"
99 alias -g W="| wc -l"
100
101 git_common="--oneline --abbrev-commit"
102 alias Gl="git log $git_common --graph --decorate=short"
103 alias Gr="git --no-pager log $git_common -n 20 | perl -ne 'print \"@~\$n \$_\"; \$n++'"
104 alias Grr="git --no-pager log $git_common --graph -n 1024 | vi -c 'e ++enc=utf8' -"
105 alias Grpck="git gc --prune=now ; git repack -a -d --depth=4095 --window=10240"
106
107 bindkey -s "\eOQ" " git status\n" # F2
108 bindkey -s "\eOR" " git status --short\n" # F3
109 # }}}
110
111 # grep {{{
112 GREP=/usr/local/bin/grep
113 GREP_ARGS="--color=always --with-filename --line-number --recursive"
114 LESS_COLORED="less --RAW-CONTROL-CHARS"
115 g() {
116     $GREP ${=GREP_ARGS} $@ | ${=LESS_COLORED}
117 }
118 GS() {
119     $GREP ${=GREP_ARGS} $@ | sort --numeric-sort | ${=LESS_COLORED}
120 }
121 alias -g G="| $GREP --color"
122 alias gg="git grep "
123 # }}}
124
125 # GPG agent {{{
126 GPG_TTY=$(tty)
127 export GPG_TTY
128 # }}}
129
130 # Virtualenv {{{
131 venv() {
132     . /usr/local/bin/virtualenvwrapper.sh
133 }
134 # }}}
135
136 # Mail {{{
137 mailpath=(
138     ~/mail/mbox"?Neue Nachrichten in =mbox"
139     ~/mail/arbeit"?Neue Nachrichten in =arbeit"
140 )
141 alias arr="mutt -f =arbeit -e 'source ~/.mutt/accounts/stcnet.ru'"
142 alias rss="mutt -f =rss"
143 bindkey -s "\eOP" " inc\n" # F1
144 # }}}
145
146 # Calculator {{{
147 autoload -U zcalc
148 alias zc="zcalc"
149 # }}}
150
151
152 # Completion {{{
153 zstyle ":completion:*:functions" ignored-patterns "_*"
154 zstyle ":completion:*" matcher-list "" 'm:{a-z\-}={A-Z\_}' 'r:|?=** m:{a-z\-}={A-Z\_}'
155 _mycomp () {
156     [ $CURRENT -eq 1 ] && _command_names || _files
157 }
158 zstyle ":completion:*" completer _mycomp _parameters
159 autoload -U compinit ; compinit -d /tmp/.zcompdump
160 zstyle ":completion:*:default" list-colors ""
161 autoload -U complist
162 export LISTMAX=9999
163 # }}}
164
165 # Highlighting {{{
166 ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
167 . ~/work/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
168 typeset -A ZSH_HIGHLIGHT_STYLES
169 ZSH_HIGHLIGHT_STYLES[globbing]="fg=magenta"
170 ZSH_HIGHLIGHT_STYLES[history-expansion]="fg=magenta"
171 ZSH_HIGHLIGHT_STYLES[commandseparator]="fg=red"
172 ZSH_HIGHLIGHT_STYLES[redirection]="fg=red"
173 ZSH_HIGHLIGHT_STYLES[assign]="fg=cyan"
174 # }}}
175
176 # Autosuggestion {{{
177 . ~/work/zsh-autosuggestions/zsh-autosuggestions.zsh
178 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=6"
179 # }}}
180