]> Sergey Matveev's repositories - dotfiles.git/blob - zsh/.zshrc
Named directories in zsh
[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 setopt RM_STAR_SILENT
12 export LISTMAX=9999
13 # }}}
14
15 # Vi mode {{{
16 bindkey -v
17 export KEYTIMEOUT=1
18 # }}}
19
20 # Home/end {{{
21 bindkey "^[[1~" beginning-of-line
22 bindkey "^[[4~" end-of-line
23 # }}}
24
25 # Command-line editing {{{
26 autoload -U edit-command-line
27 zle -N edit-command-line
28 bindkey -M vicmd v edit-command-line
29 # }}}
30
31 # History search {{{
32 autoload -U history-search-end
33 zle -N history-beginning-search-backward-end history-search-end
34 zle -N history-beginning-search-forward-end history-search-end
35 bindkey "^[[A" history-beginning-search-backward-end
36 bindkey "^[[B" history-beginning-search-forward-end
37 bindkey "^R" history-incremental-pattern-search-backward
38 # }}}
39
40 # Prompt {{{
41 function zle-line-init zle-keymap-select {
42     mode_vi="${${KEYMAP/vicmd/+}/(main|viins)/-}"
43     [ $timer ] && timer_show=$(( $SECONDS - $timer ))
44     prompt="%2~|"
45     prompt+="%U${timer_show}%u|"
46     prompt+="%B%?%b"
47     prompt+="${mode_vi}"
48     prompt+="%F{magenta}%#%f "
49     PS1="$prompt"
50     zle reset-prompt
51 }
52 zle -N zle-line-init
53 zle -N zle-keymap-select
54
55 preexec() {
56     timer=$SECONDS
57 }
58
59 precmd() {
60     printf "\a\033]2;\033\\"
61 }
62 # }}}
63
64 # Aliases {{{
65 alias l="ls -AF "
66 alias ll="ls -AFl "
67 alias ssh="TERM=xterm ssh"
68 alias vi="vim"
69 alias more="less"
70 alias m="less "
71 alias -g M="| less"
72 alias mc="mc --nomouse"
73 bindkey -s "\eOS" " popd\n" # F4
74
75 f() {
76     # find . -name "*$1*" -print
77     print -C 1 **$1*
78 }
79
80 ssht() {
81     ssh -C -t "$1" tmux attach -t0
82 }
83 alias sshnm='ssh -S none'
84 # }}}
85
86 # Git {{{
87 alias Ga="git add"
88 alias Gb="git branch"
89 alias Gc="git checkout"
90 alias Gd="git diff"
91 alias Gs="git show"
92 alias Gm="git diff --name-only --diff-filter=M"
93 alias Gam="git commit --amend"
94 alias -g W="| wc -l"
95
96 git_common="--oneline --abbrev-commit"
97 alias Gl="git log $git_common --graph --decorate=short"
98 alias Gr="git --no-pager log $git_common -n 20 | perl -ne 'print \"@~\$n \$_\"; \$n++'"
99 alias Grr="git --no-pager log $git_common --graph -n 1024 | vi -c 'e ++enc=utf8' -"
100
101 bindkey -s "\eOQ" " git status\n" # F2
102 bindkey -s "\eOR" " git status --short\n" # F3
103 # }}}
104
105 # grep {{{
106 GREP=/usr/local/bin/grep
107 GREP_ARGS="--color=always --with-filename --line-number --recursive"
108 LESS_COLORED="less --RAW-CONTROL-CHARS"
109 g() {
110     $GREP ${=GREP_ARGS} $@ | ${=LESS_COLORED}
111 }
112 GS() {
113     $GREP ${=GREP_ARGS} $@ | sort --numeric-sort | ${=LESS_COLORED}
114 }
115 alias -g G="| $GREP --color"
116 alias gg="git grep "
117 # }}}
118
119 # GPG agent {{{
120 GPG_TTY=$(tty)
121 export GPG_TTY
122 # }}}
123
124 # Virtualenv {{{
125 venv() {
126     . /usr/local/bin/virtualenvwrapper.sh
127 }
128 # }}}
129
130 # Mail {{{
131 mailpath=(
132     ~/mail/mbox"?Neue Nachrichten in =mbox"
133     ~/mail/arbeit"?Neue Nachrichten in =arbeit"
134 )
135 alias arr="mutt -f =arbeit -e 'source ~/.mutt/accounts/stcnet.ru'"
136 alias rss="mutt -f =rss"
137 bindkey -s "\eOP" " inc\n" # F1
138 # }}}
139
140 # Calculator {{{
141 autoload -U zcalc
142 alias zc="zcalc"
143 # }}}
144
145 # Named directories {{{
146 . ~/.zhashd
147 # }}}
148
149 # Completion {{{
150 zstyle ":completion:*:functions" ignored-patterns "_*"
151 zstyle ":completion:*" matcher-list "" 'm:{a-z\-}={A-Z\_}' 'r:|?=** m:{a-z\-}={A-Z\_}'
152 _mycomp () {
153     [ $CURRENT -eq 1 ] && _command_names || _files && return 0
154     # MAGIC_EQUAL_SUBST {{{
155     [[ "$PREFIX" = *\=* ]] || return 1
156     compstate[parameter]="${PREFIX%%\=*}"
157     compset -P 1 "*="
158     _value
159     # }}}
160 }
161 zstyle ":completion:*" completer _mycomp _parameters
162 autoload -U compinit ; compinit -d /tmp/.zcompdump
163 zstyle ":completion:*:default" list-colors ""
164 autoload -U complist
165 # }}}
166
167 # Highlighting {{{
168 ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
169 . ~/work/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
170 typeset -A ZSH_HIGHLIGHT_STYLES
171 ZSH_HIGHLIGHT_STYLES[globbing]="fg=magenta"
172 ZSH_HIGHLIGHT_STYLES[history-expansion]="fg=magenta"
173 ZSH_HIGHLIGHT_STYLES[commandseparator]="fg=red"
174 ZSH_HIGHLIGHT_STYLES[redirection]="fg=red"
175 ZSH_HIGHLIGHT_STYLES[assign]="fg=cyan"
176 # }}}
177
178 # Autosuggestion {{{
179 . ~/work/zsh-autosuggestions/zsh-autosuggestions.zsh
180 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=6"
181 # }}}
182