summaryrefslogtreecommitdiff
path: root/zsh/zshrc
blob: 9e473c4d07f1ef387e99424145b7d9bc97a15a60 (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
source ~/.config/zsh/antigen.zsh

if command -v git >/dev/null && [ ! -d ~/.config/zsh/powerlevel10k ]; then
	echo "info: installing p10k"
	git clone --depth 1 --single-branch https://github.com/romkatv/powerlevel10k.git ~/.config/zsh/powerlevel10k
fi

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
	source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

source ~/.config/zsh/p10k/powerlevel10k.zsh-theme
source ~/.config/zsh/conf.d/*.zsh
source ~/.config/zsh/termsupport.zsh
source ~/.config/zsh/title.zsh

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 theme romkatv/powerlevel10k
antigen apply

# {{{ Exports
#export GOPROXY=https://proxy.neonxp.ru
export GOPRIVATE=devopar.hippoparking.ru,gitlab.sovcombank.group
export EDITOR="nvim"
#export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock
export ANDROID_HOME=$HOME/projects/android/
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:~/.local/bin:~/go/bin:~/.cargo/bin
export GOBIN=~/go/bin
export GPG_TTY=$(tty)
export LS_OPTIONS='--color=auto'
eval "$(dircolors -b)"

fpath+="~/.config/zsh/comp"
# }}}

# {{{ 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
[[ ! -f `which exa` ]] || alias ls="exa" && alias ll="exa -l"
# }}}

# {{{ Functions
function tk() { mkdir -p $1; cd $1; }
# }}}

# {{{ 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//\/[&.;]}

autoload -U compinit colors zcalc
compinit -d

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

# ctrl + space accept suggestion
bindkey "^ " autosuggest-accept
# }}}

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
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# }}}