-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
410 lines (315 loc) · 13.4 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# intika --> https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes#intika-theme
# ZSH_THEME="robbyrussell"
ZSH_THEME="garyblessington"
# todo: https://github.com/liquidprompt/liquidprompt
# antigen bundle liquidprompt/liquidprompt
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
#? +-----------------------+
#? | Antigen |
#? +-----------------------+
# plugins: https://github.com/unixorn/awesome-zsh-plugins
# antigen bundle github-user/repo --branch=main
# ~/.antigen folder where all the plugins are installed
# uninstall plugin: just comment `antigen bundle` line & source .zshrc & restart shell (and zellij session..; just `zellij -ka` then restore session)
# todo: replace with https://github.com/mattmc3/antidote
# todo: https://github.com/MichaelAquilina/zsh-auto-notify
# Load Antigen
source "$HOME/antigen.zsh"
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# Bundles from the default repo (robbyrussell's oh-my-zsh).
# fzf-tab needs to be loaded after compinit, but before plugins which will wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting!!
# fzf-tab ALSO needs fzf installed, otherwise it cannot work!
# todo: docs https://github.com/Aloxaf/fzf-tab#usage
# antigen bundle Aloxaf/fzf-tab
antigen bundle zsh-interactive-cd
antigen bundle git
antigen bundle git-auto-fetch
antigen bundle command-not-found
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle MichaelAquilina/zsh-auto-notify
antigen bundle aliases
# https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-reset-the-completion-cache
antigen bundle zsh-users/zsh-autosuggestions
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
# history: ~/.zsh_history
# https://github.com/zsh-users/zsh-autosuggestions/issues/751#issuecomment-1774018197
autoload -Uz compinit && compinit
antigen bundle z
antigen apply
# colorls
# source $(dirname $(gem which colorls))/tab_complete.sh
#? +-----------------------+
#? | znap! |
#? +-----------------------+
# Download Znap, if it's not there yet.
[[ -r ~/Repos/znap/znap.zsh ]] ||
git clone --depth 1 -- \
https://github.com/marlonrichert/zsh-snap.git ~/Repos/znap
source ~/Repos/znap/znap.zsh # Start Znap
# znap source marlonrichert/zsh-autocomplete
# znap install bigH/git-fuzzy
#? +-----------------------+
#? | zinit |
#? +-----------------------+
# https://github.com/zdharma-continuum/zinit
# zinit ice as"program" pick"bin/git-fuzzy"
# zinit light bigH/git-fuzzy
#? +-----------------------+
#? | svonjoi |
#? +-----------------------+
# configpath: ~/.config/nvim
# datapath ~/.local/share/nvim
export EDITOR=nvim
export KLOUD="/mnt/gdrive_loadmaks/"
export POLYBAR_SCRIPTS="$HOME/bin/polybar_scripts"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
# exa, lsd accepts the same parms
alias l='exa --all --group-directories-first'
alias ll='lsd -l --all --group-directories-first'
alias llt='exa --tree --group-directories-first'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias man='batman'
alias Nvim=nvim_selecting_config
alias nvim1='NVIM_APPNAME=nvim-kickstart nvim'
alias nvim2='NVIM_APPNAME=nvim-lazyvim nvim'
alias dump='~/.config/scripts/dump_svonux/dump_svonux.sh --full'
# https://stackoverflow.com/a/39839346/16719196
# shopt -s cdable_vars
# export ddev=$HOME/Documents/dev/
# export dsanjuan2=$HOME/Documents/dev/sanjuan2/
# export dgdrive_loadmaks=$HOME/Documents/gdrive_loadmaks/
# export dgdrive_svonjoi=$HOME/Documents/gdrive_svonjoi/
# export dpkm=/media/svonjoi/Data/private/pkm_vampir/
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# he instalado esto pero tira de su propia bdd asi que he vuelto con zsh-z para
# no volver a completar la bdd, xq tampoco he visto ninguna mejora
# estos son dirs donde cayeron los archivos que se instalaron con el script q viene en el github
# Installed zoxide to /home/svonjoi/.local/bin
# Installed manpages to /home/svonjoi/.local/share/man
# add zoxide to zsh shell
# eval "$(zoxide init zsh)"
# +-----------------------+
# | FUNCTIONS |
# +-----------------------+
@c(){
xargs echo -n | xclip -selection clipboard
}
# https://www.cyberciti.biz/faq/how-do-i-copy-a-file-to-the-clipboard-in-linux/
# multiline
@c2() {
xclip -sel clip
}
yankpath () {
realpath $1 | yank
}
# Add a # to the front of the command (so it becomes a comment)
copy_last_command () {
history | tail -n 1 | sed "s/[[:digit:]]* //" | sed "s/^#//" | xclip
}
zle -N copy_last_command
bindkey '^k' copy_last_command
if [[ -n $DISPLAY ]]; then
copy_line_to_x_clipboard() {
echo -n $BUFFER | xclip -selection clipboard
zle reset-prompt
}
zle -N copy_line_to_x_clipboard
bindkey '^y' copy_line_to_x_clipboard
fi
# yadm
function yc() {
cd ~
yadm enter lazygit
cd -
}
function apply_wallpaper() {
# nitrogen --restore
/usr/bin/dwall -s bitday
}
# +-----------------------+
# | $PATH |
# +-----------------------+
# the directory must have permissions: chmod -R 755 ~/bin
if [ -d $HOME/.config/scripts ]; then
PATH=$PATH:$HOME/bin
fi
# export all ~/bin subdirectories
for dir in $HOME/.config/scripts/*/ ; do
export PATH="$PATH:$dir"
done
# sioyek
# PATH="$HOME/dev/third/sioyek/build${PATH:+:${PATH}}"; export PATH;
# export PATH="$PATH:$HOME/.config/i3/scripts/"
# kitty fix ssh issue
# https://sw.kovidgoyal.net/kitty/faq/#i-get-errors-about-the-terminal-being-unknown-or-opening-the-terminal-failing-or-functional-keys-like-arrow-keys-don-t-work
# [ "$TERM" = "xterm-kitty" ] && alias ssh="kitty +kitten ssh"
#
# UPD. este puto fix crea nuevo problema - en zellij se queda colgao al conectarse
# https://github.com/kovidgoyal/kitty/issues/5900
#
# UPD. Надо китти на сервак ставить или терминфо как минимум (не пробовал)
# UPD. в mosh проблем нету
PATH="/home/svonjoi/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/svonjoi/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/svonjoi/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/svonjoi/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/svonjoi/perl5"; export PERL_MM_OPT;
# Fix zsh autosuggestions keybind for arrow keys
# zle-line-init() {}
# bindkey '\e[A' history-beginning-search-backward
# bindkey '\e[B' history-beginning-search-forward
# bindkey "^[[A" history-beginning-search-backward
# bindkey "^[[B" history-beginning-search-forward
# colored man pager with bat, using bat configured theme
# just install bat-extras and add this customization
# https://github.com/eth-p/bat-extras/blob/master/doc/batman.md#changing-the-theme
# https://stackoverflow.com/questions/42822661/oh-my-zsh-git-maximum-nested-function-level-reached
function batman() {
BAT_THEME="Solarized (dark)" command batman "$@"
return $?
}
nvim_selecting_config() {
# Assumes all configs exist in directories named ~/.config/nvim-*
local config=$(fd --max-depth 1 --glob 'nvim-*' ~/.config | fzf --prompt="Neovim Configs > " --height=~50% --layout=reverse --border --exit-0)
# If I exit fzf without selecting a config, don't open Neovim
[[ -z $config ]] && echo "No config selected" && return
set -x
# Open Neovim with the selected config
NVIM_APPNAME=$(basename $config) nvim $@
}
# https://gist.github.com/elijahmanor/b279553c0132bfad7eae23e34ceb593b
function nvims2() {
set -x
items=$(find $HOME/.config -maxdepth 2 -name "init.lua" -type f -execdir sh -c 'pwd | xargs basename' \;)
selected=$(printf "%s\n" "${items[@]}" | FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS-} --preview-window 'right:border-left:50%:<40(right:border-left:50%:hidden)' --preview 'lsd -l -A --tree --depth=1 --color=always --blocks=size,name ~/.config/{} | head -200'" fzf )
if [[ -z $selected ]]; then
return 0
elif [[ $selected == "nvim" ]]; then
selected="nvim-kickstart"
fi
echo "$@"
~/.config/scripts/helpers/nvim_runner.sh $selected
# NVIM_APPNAME=$selected nvim "$@"
}
bindkey -s "^v" "nvims2\n"
bindkey -s "^z" "source ~/.zshrc && omz reload";
function remove_ws_layout() {
~/.config/scripts/i3_scripts/ws/remove_ws_layout.sh
}
zle -N remove_ws_layout
bindkey "^3" remove_ws_layout
FZF_ALIAS_OPTS=${FZF_ALIAS_OPTS:-"--preview-window up:3:hidden:wrap"}
function fzf_alias() {
local selection
# use sed with column to work around MacOS/BSD column not having a -l option
if selection=$(alias |
sed 's/=/\t/' |
column -s ' ' -t |
FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS $FZF_ALIAS_OPTS" fzf --preview "echo {2..}" --query="$BUFFER" |
awk '{ print $1 }'); then
BUFFER=$selection
CURSOR=$#BUFFER
fi
zle redisplay
}
zle -N fzf_alias
# bindkey "^a" fzf_alias
bindkey -M emacs '\ea' fzf_alias
bindkey -M vicmd '\ea' fzf_alias
bindkey -M viins '\ea' fzf_alias
#
# fzf shell integration
# TODO: много полезняшек
# https://junegunn.github.io/fzf/shell-integration/
source <(fzf --zsh)
# Preview file content using bat (https://github.com/sharkdp/bat)
export FZF_CTRL_T_OPTS="
--walker-skip .git,node_modules,target
--preview 'bat -n --color=always {}'
--bind 'ctrl-/:change-preview-window(down|hidden|)'"