summaryrefslogtreecommitdiff
path: root/zsh/.zshrc
blob: 48052081417f4660920242c0cff8d5605ead3c12 (plain) (blame)
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
source ~/.config/zsh/antigen.zsh
source ~/.config/zsh/conf.d/*.zsh
source ~/.config/zsh/termsupport.zsh
source ~/.config/zsh/title.zsh

# {{{ Exports
export GOPROXY=https://goproxy.ru,direct
export GONOPROXY=*.sovcombank.group
export GOSUMDB=off
export GOPRIVATE=devopar.hippoparking.ru,gitlab.sovcombank.group
export EDITOR="nvim"
#export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export GOPATH=~/go
export PATH=$PATH:~/.local/bin:$GOPATH/bin #:~/.cargo/bin:~/.config/v-analyzer/bin:~/projects/tinygo/bin
export GOBIN=$GOPATH/bin
export GPG_TTY=$(tty)
export LS_OPTIONS='--color=auto'

eval "$(dircolors -b)"

# }}}

antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-history-substring-search
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-completions
antigen bundle ael-code/zsh-colored-man-pages
antigen apply

# {{{ Aliases
alias ls='ls $LS_OPTIONS -F'
alias l='ls $LS_OPTIONS -F'
alias j="sudo journalctl"
alias s='sudo'
alias sctl="sudo systemctl"
alias ll="ls -AFhl"
alias cp="cp -i"
alias gitpush="git add . && git commit --amend --no-edit && git push -f"
alias yu="ssh-add -e /usr/lib/x86_64-linux-gnu/libykcs11.so; ssh-add -s /usr/lib/x86_64-linux-gnu/libykcs11.so"
alias n="nvim"
alias nv="nvim ."
alias cp="cp -i"
alias df="df -h"
alias free="free -m"
alias gitu='git add . && git commit && git push'
alias g=git
alias share='wl-paste | curl -si -d @- https://nixshare.ru/paste/clipboard.txt | grep "location:" | sed -s "s/location: //" | wl-copy'
alias p=python3
alias t=todo.sh
alias ed=gnome-text-editor
[[ ! -f `which exa` ]] || alias ls="exa" && alias ll="exa -l"
compdef _todo t
# }}}

# {{{ Functions
foreground () { fg }
zle -N foreground
clearscr () { clear }
zle -N clearscr


function tk() { mkdir -p $1; cd $1; }
function powerline_precmd() {
    PS1="$($GOPATH/bin/powerline-go -hostname-only-if-ssh -cwd-max-depth 1 -cwd-mode dironly  -error $? -jobs ${${(%):%j}:-0})"

    # Uncomment the following line to automatically clear errors after showing
    # them once. This not only clears the error for powerline-go, but also for
    # everything else you run in that shell. Don't enable this if you're not
    # sure this is what you want.

    set "?"
}

function install_powerline_precmd() {
  for s in "${precmd_functions[@]}"; do
    if [ "$s" = "powerline_precmd" ]; then
      return
    fi
  done
  precmd_functions+=(powerline_precmd)
}

if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
    install_powerline_precmd
fi
# }}}

# {{{ Options section
setopt correct				# Auto correct mistakes
setopt extendedglob			# Extended globbing. Allows using regular expressions with *
setopt nocaseglob			# Case insensitive globbing
setopt rcexpandparam		# Array expension with parameters
setopt nocheckjobs			# Don"t warn about running processes when exiting
setopt numericglobsort		# Sort filenames numerically when it makes sense
setopt nobeep				# No beep
setopt appendhistory		# Immediately append history instead of overwriting
setopt histignorealldups	# If a new command is a duplicate, remove the older one
setopt autocd				# if only directory path is entered, cd there.
setopt inc_append_history	# save commands are added to the history immediately, otherwise only when shell exits.
setopt histignorespace		# Don"t save commands that start with space

zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' # Case insensitive tab completion
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"	# Colored completion (different colors for dirs/files/etc)
zstyle ':completion:*' rehash true						# automatically find new executables in path
zstyle ':completion:*' menu select						# Highlight menu selection
# Speed up completions
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache

zstyle ":completion:*:processes" command "ps -ax"
zstyle ":completion:*:*:kill:*:processes" list-colors "=(#b) #([0-9]#)*=0=01;32"
zstyle ":completion:*:*:kill:*" menu yes select
zstyle ":completion:*:kill:*"	 force-list always

zstyle ":completion:*:processes-names" command "ps -e -o comm="
zstyle ":completion:*:*:killall:*" menu yes select
zstyle ":completion:*:killall:*"	 force-list always

HISTFILE=~/.zsh_history
HISTSIZE=100000
SAVEHIST=100000
WORDCHARS=${WORDCHARS//\/[&.;]}

fpath=(~/.config/zsh/comp $fpath)
autoload -U compinit colors zcalc
compinit -d

autoload -Uz compinit &&  compinit

autoload -U add-zsh-hook
add-zsh-hook precmd mzc_termsupport_precmd
add-zsh-hook preexec mzc_termsupport_preexec
add-zsh-hook precmd mzc_termsupport_cwd

colors

zmodload zsh/terminfo
# }}}

# {{{ Binds
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down

bindkey -e
bindkey "^[[7~" beginning-of-line					# Home key
bindkey "^[[H" beginning-of-line					# Home key
if [[ "${terminfo[khome]}" != "" ]]; then
	bindkey "${terminfo[khome]}" beginning-of-line	# [Home] - Go to beginning
fi
bindkey "^[[8~" end-of-line							# End key
bindkey "^[[F" end-of-line							# End key
if [[ "${terminfo[kend]}" != "" ]]; then
	bindkey "${terminfo[kend]}" end-of-line			# [End] - Go to end of line
fi
bindkey "^[[2~" overwrite-mode						# Insert key
bindkey "^[[3~" delete-char							# Delete key
bindkey "^[[C"	forward-char						# Right key
bindkey "^[[D"	backward-char						# Left key
bindkey "^[[5~" history-beginning-search-backward	# Page up key
bindkey "^[[6~" history-beginning-search-forward	# Page down key

# Navigate words with ctrl+arrow keys
bindkey "^[Oc" forward-word
bindkey "^[Od" backward-word
bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word
bindkey "^H" backward-kill-word		# delete previous word with ctrl+backspace
bindkey "^[[Z" undo					# Shift+tab undo last action
bindkey "^z" foreground
# ctrl + space accept suggestion
bindkey "^ " autosuggest-accept


bindkey "^K" clearscr
# }}}

ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
# {{{ Overwriting
source ~/.config/zsh/theme.zsh
[[ ! -f env.sh ]] || source ./env.sh
[[ ! -f ~/.zshrc.local.zsh ]] || source ~/.zshrc.local.zsh
# }}}