-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
270 lines (219 loc) · 7.47 KB
/
zshrc
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
source /etc/profile
# https://github.com/zsh-users/zsh-completions
fpath=(~/.zsh/completion /usr/local/share/zsh-completions $fpath)
autoload -U compinit
compinit -u
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -ap zsh/mapfile mapfile
# Allow tab completion in the middle of a word
setopt COMPLETE_IN_WORD
# colors for ls: uses gls from the coreutils
eval `gdircolors ~/.dir_colors`
ZLS_COLORS="$LS_COLORS"
export ZLS_COLORS
zmodload zsh/complist
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:processes' command 'ps -xuf'
zstyle ':completion:*:processes' sort false
zstyle ':completion:*:processes-names' command 'ps xho command'
zstyle ':completion:*' menu select=long-list select=0
zstyle ':completion:*' old-menu false
zstyle ':completion:*' original true
zstyle ':completion:*' substitute 1
zstyle ':completion:*' use-compctl true
zstyle ':completion:*' verbose true
zstyle ':completion:*' word true
# For git
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
# zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' stagedstr "+"
zstyle ':vcs_info:*' unstagedstr "!"
zstyle ':vcs_info:*' formats '[%b%F{red}%c%u%F{green}]'
setopt PROMPT_SUBST
# History
export HISTFILE=~/.zhistory
SAVEHIST=5000
HISTSIZE=5000
setopt APPEND_HISTORY
# For sharing history between zsh processes
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_REDUCE_BLANKS
# Disable mail checking
MAILCHECK=0
autoload -U colors zsh/terminfo
colors
# File aliases
alias -s {avi,mpeg,mpg,mov,m2v,flv}=mplayer
alias -s log=less
alias -s blog=nvim
# Common aliases
alias a="alias"
alias cl='clear'
alias ds="du -s ."
alias reload="source ~/.zshrc"
alias o="open ."
alias m="make"
# Eza
alias ls="eza --icons --hyperlink --color=auto"
alias ll="eza --icons --hyperlink -lh --color=auto"
alias lt="eza --tree --level=2 --long --icons --git"
# Git aliases
alias gc="git commit -a"
alias go="git checkout"
alias gob="git checkout -b"
alias gd="git diff"
alias gb="git branch"
alias gl="git lg"
alias gm="git merge"
alias gpo="git push origin"
alias gpu="git pull --rebase origin"
alias gpom="git push origin master"
alias gpum="git pull --rebase origin master"
# Android Studio alias
alias ast="open -a /Applications/Android\ Studio.app ."
# Flutter aliases
alias fu="flutter upgrade"
# Hashes
hash -d wm=~/work/mobile
hash -d wa=~/work/android
hash -d d=~/.dotfiles
hash -d wx=~/work/android/xbasoft
# Errors autocorrection
setopt CORRECT_ALL
SPROMPT="Помилка! Ви хотіли ввести %r замість %R? ([Y]es/[N]o/[E]dit/[A]bort) "
# Moving by dirs without cd
setopt autocd
# Prompt: red color for root and yellow for non-root
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE;
do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
if (( EUID == 0))
then
eval PR_COLOR=$PR_RED
else
eval PR_COLOR=$PR_YELLOW
fi
CDPATH=.:~:~/work
PATH=$PATH:~/work/android/android-sdk-macosx/tools/:~/bin:~/work/android/flutter/flutter/.pub-cache/bin:~/.pub-cache/bin
PATH=~/work/android/flutter/flutter/bin:$PATH
GIT_SSL_NO_VERIFY=1
# vi-mode settings
bindkey -v
case $TERM in
xterm* | rxvt*)
preexec() {print -Pn "\e]0;$1\a"}
precmd() {
print -Pn "\e]0;%~\a"
vcs_info
}
bindkey "^[[2~" yank
bindkey "^[[3~" delete-char
bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
bindkey "^[[7~" beginning-of-line
bindkey "^[[8~" end-of-line
bindkey "^[e" expand-cmd-path ## C-e for expanding path of typed command
bindkey "^[[A" up-line-or-search ## up arrow for back-history-search
bindkey "^[[B" down-line-or-search ## down arrow for fwd-history-search
bindkey " " magic-space ## do history expansion on space
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward
bindkey '^?' backward-delete-char
bindkey '^H' backward-delete-char
;;
esac
# F1 for opening help
autoload zsh/terminfo
bindkey $terminfo[kf1] run-help
function zle-line-init zle-keymap-select {
VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}"
RPROMPT="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
export KEYTIMEOUT=1
PROMPT='%B[(20%D) $PR_COLOR%n$PR_NO_COLOUR] $PR_WHITE%~%F{green}${vcs_info_msg_0_}$PR_WHITE%#$PR_NO_COLOUR '
RPROMPT=$'%(?,%{\e[34m%}%m%{\e[0m%},%{\e[1;31m%}:(%{\e[0m%})'
# Sourcing of other files
source $HOME/.zsh/functions.zsh
export EDITOR=nvim
# https://github.com/zsh-users/zsh-syntax-highlighting
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=magenta'
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=magenta,bold'
# todotxt
export TODOTXT_DEFAULT_ACTION=ls
alias t=todo.sh
compdef t='todo.sh'
alias tb='todo.sh birdseye'
alias ta='tp adda'
# nginx
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
## [Completion]
## Completion scripts setup. Remove the following line to uninstall
[[ -f /Users/vadimkhohlov/.dart-cli-completion/zsh-config.zsh ]] && . /Users/vadimkhohlov/.dart-cli-completion/zsh-config.zsh || true
## [/Completion]
# Spaceship prompt
# https://github.com/spaceship-prompt
#
source ~/.zsh/spaceship/spaceship-flutter/spaceship-flutter.plugin.zsh
# must be placed after all additional plugins
source "/usr/local/opt/spaceship/spaceship.zsh"
# FZF
# https://github.com/junegunn/fzf
#
eval "$(fzf --zsh)"
# --- setup fzf theme ---
fg="#CBE0F0"
bg="#011628"
bg_highlight="#143652"
purple="#B388FF"
blue="#06BCE4"
cyan="#2CF9ED"
export FZF_DEFAULT_OPTS="--color=fg:${fg},bg:${bg},hl:${purple},fg+:${fg},bg+:${bg_highlight},hl+:${purple},info:${blue},prompt:${cyan},pointer:${cyan},marker:${cyan},spinner:${cyan},header:${cyan}"
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
# Use fd (https://github.com/sharkdp/fd) for listing path candidates.
_fzf_compgen_path() {
fd --hidden --exclude .git . "$1"
}
# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fd --type=d --hidden --exclude .git . "$1"
}
show_file_or_dir_preview="if [ -d {} ]; then eza --tree --color=always {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# Advanced customization of fzf options via _fzf_comprun function
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo ${}'" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview "$show_file_or_dir_preview" "$@" ;;
esac
}
# Bat (better cat)
# https://github.com/sharkdp/bat
export BAT_THEME=tokyonight_night
# Zoxide (better cd)
# https://github.com/ajeetdsouza/zoxide
eval "$(zoxide init zsh)"