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