-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc.user
281 lines (223 loc) · 11.6 KB
/
zshrc.user
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
# PC
[[ -d "/home/$USER/.local/bin" ]] && [[ ":$PATH:" != *":/home/$USER/.local/bin:"* ]] && export PATH=/home/$USER/.local/bin:$PATH
[[ -d "/home/$USER/.cargo/bin" ]] && [[ ":$PATH:" != *":/home/$USER/.cargo/bin:"* ]] && export PATH=/home/$USER/.cargo/bin:$PATH
# raspberry pi
[[ -d "/home/.local/bin" ]] && [[ ":$PATH:" != *":/home/.local/bin:"* ]] && export PATH=/home/.local/bin:$PATH
[[ -d "/home/.cargo/bin" ]] && [[ ":$PATH:" != *":/home/.cargo/bin:"* ]] && export PATH=/home/.cargo/bin:$PATH
if [[ $0 =~ "zsh" ]]
then
[ -f ~/.zshrc.$USER.work ] && source ~/.zshrc.$USER.work
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && source ~/.autojump/etc/profile.d/autojump.sh
alias -s cpp="nvim "
alias -s C="nvim "
alias -s h="nvim "
alias -s log="nvim "
alias -s py="nvim "
alias -s tcl="nvim "
alias -s txt="nvim "
alias -s v="nvim "
alias -s sv="nvim "
alias -s vh="nvim "
alias -s svh="nvim "
fi
export EDITOR=nvim
export P4EDITOR=nvim
export P4DIFF="nvim -d"
if [[ $0 =~ "bash" ]]
then
export EDITOR=/u/urmish/usr/local/bin/vim
export P4EDITOR=$EDITOR
export P4DIFF="$EDITOR -d"
function nvim () { /u/urmish/usr/local/bin/vim $@ ; }
alias ealias="vim ~/.bashrc.$USER"
alias salias="source ~/.bashrc.$USER"
[ -f ~/usr/local/share/z/z.sh ] && source ~/usr/local/share/z/z.sh
# export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: '
# export PS1='\[\033[40;33;01m\]\h: \[\e[m\]'
hostnameStr=`hostname`
if [[ $hostnameStr =~ "odcvde" ]]
then
promptStr=""
else
promptStr=`echo $hostname_str | sed -e 's/us01//'`
fi
export PS1='\[\033[01;33m\]${promptStr}prompt:> \[\e[m\]'
else
alias salias="source ~/.zshrc.user"
alias ealias="vim ~/.zshrc.user"
fi
# graveyard var for rip (rm replacement)
export GRAVEYARD=/tmp/$USER/graveyard
if [[ $0 =~ "zsh" ]]
then
function ls () { exa --icons $* ; }
function v () { exa --icons -l --sort new $@ ; }
else
alias ls='ls --color=auto'
alias v='ls --color=auto -ltr'
fi
function p () { pwd ; }
export BAT_THEME="Solarized (dark)"
export BAT_CONFIG_PATH="$HOME/.config/bat/config"
# alias fd='$local_dir/bin/fd'
alias lc="wc -l"
alias lg="ls | rg"
alias hig="history | rg"
function g () { rg $@ ; }
alias e-="nvim -"
function e () { nvim $@ ; }
function eo () { e -o $@ ; }
function eO () { e -O $@ ; }
function r () { e -R $@ ; }
alias vt="nvim -t"
# function vt () { e -t $@ ; }
function vd () { e -d $@ ; }
function evim () { e ~/.vimrc ; }
function einit () { e ~/.config/nvim/init.lua ; }
function etmux () { e ~/.tmux.conf ; }
function update () { sudo apt update -y ; }
function upgrade () { sudo apt upgrade -y ; }
alias tmux="tmux -2"
alias takeover="tmux detach -a"
alias ..="cd ../"
alias ...="cd ../../"
alias ....="cd ../../../"
alias .....="cd ../../../../"
alias rmf="rm -f"
alias rmrf="rm -rf"
alias cpr="cp -r"
# function dus () { du -hc --summarizea $@ ; }
function dfh () { df -h . ; }
function dus () { sn all $@ ; }
alias rp="readlink -e "
alias rp.="readlink -e ."
alias tf='tail -f'
alias yaudio="youtube-dl --extract-audio --audio-quality 0"
function dirdiff () {
# Shell-escape each path:
DIR1=$(printf '%q' "$1"); shift
DIR2=$(printf '%q' "$1"); shift
vim $@ -c "DirDiff $DIR1 $DIR2"
}
function topu () { top -u $USER ; }
# export TLDR_HEADER='yellow bold underline'
# export TLDR_QUOTE='italic'
# export TLDR_DESCRIPTION='green'
# export TLDR_CODE='violet'
# export TLDR_PARAM='yellow'
# export LS_COLORS='rs=0:di=1;36:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:'
export LS_COLORS='rs=0:di=1;36:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30:ow=34:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:'
function compile_ag() {
./autogen.sh
PCRE_LIBS="-L$local_dir/lib -lpcre" PCRE_CFLAGS=-I$local_dir/include/pcre2 ./configure --prefix=$local_dir
}
function compile_nvim() {
make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=$local_dir USE_BUNDLED=OFF LIBLUV_LIBRARY=$local_dir/lib/libluv.so LIBLUV_INCLUDE_DIR=$local_dir/include/luv -j16 install
}
function compile_vim () {
set -x
# ./configure --prefix=$local_dir --with-tclsh=~/usr/local/bin/tclsh --enable-luainterp=yes --with-lua-prefix=$local_dir --enable-terminal --with-features=huge --enable-tclinterp=no --enable-perlinterp=no --disable-cscope --enable-python3interp=dynamic --disable-gui --disable-gpm --disable-xim --disable-fontset --disable-rightleft --disable-arabic --disable-darwin --disable-smack --disable-xsmp -disable-xsmp-interact --disable-gtk2-check --disable-gtktest --disable-acl --disable-canberra
# CFLAGS='-g -gdwarf-4 -DDEBUG -O0 -fno-omit-frame-pointer' ./configure --prefix=$local_dir --with-tclsh=~/usr/local/bin/tclsh --enable-luainterp=yes --with-lua-prefix=$local_dir --enable-terminal --with-features=huge --enable-tclinterp=no --enable-perlinterp=no --disable-cscope --enable-python3interp=yes --disable-gui --disable-gpm --disable-xim --disable-fontset --disable-rightleft --disable-arabic --disable-darwin --disable-smack --disable-xsmp -disable-xsmp-interact --disable-gtk2-check --disable-gtktest --disable-acl --disable-canberra
./configure --prefix=$local_dir --with-tclsh=~/usr/local/bin/tclsh --enable-luainterp=yes --with-lua-prefix=$local_dir --enable-terminal --with-features=huge --enable-tclinterp=no --enable-perlinterp=no --disable-cscope --enable-python3interp=yes --disable-gui --disable-gpm --disable-xim --disable-fontset --disable-rightleft --disable-arabic --disable-darwin --disable-smack --disable-xsmp -disable-xsmp-interact --disable-gtk2-check --disable-gtktest --disable-acl --disable-canberra
# make -j16
# make install
set +x
}
function pip_upgrade_all {
pip install --upgrade pip ;
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U ;
}
function compile_gcc () {
./configure --prefix=$local_dir --disable-multilib --disable-nls --with-gmp=$local_dir --with-mpfr=$local_dir --with-mpc=$local_dir
}
# FZF settings: Plugin must be installed/maintained via vim
function efzf () { vim $(fzf) ; }
export FZF_COMMON_OPTS="--exact --ansi --reverse --height=70% --preview-window=right:60%:wrap --bind=ctrl-k:down,ctrl-l:up,ctrl-j:accept"
export FZF_PREVIEW_COMMAND="bat --color=always --style=numbers --line-range 1: {} || cat {} || tree -C {}"
export FZF_DEFAULT_OPTS="$FZF_COMMON_OPTS --preview='($FZF_PREVIEW_COMMAND) 2> /dev/null'"
# export FZF_CTRL_T_OPTS="--min-height 30 --preview-window noborder $FZF_COMMON_OPTS --preview='($FZF_PREVIEW_COMMAND) 2> /dev/null'"
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview' --border"
if [[ $0 =~ "zsh" ]]
then
# =============================================================================
# Plugins
# =============================================================================
if [[ ! -d ~/.zsh/antigen ]]
then
# Install package manager.
# It keeps the installed packages under ~/.antigen
git clone https://github.com/zsh-users/antigen.git ~/.zsh/antigen
fi
source ~/.zsh/antigen/antigen.zsh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
antigen bundle fd
antigen bundle ripgrep
antigen bundle extract
antigen bundle colored-man-pages
# Jump around directories using Z
antigen bundle agkozak/zsh-z
ZSHZ_UNCOMMON=1
antigen theme denysdovhan/spaceship-prompt
# git
SPACESHIP_PROMPT_ORDER=(
time
dir
exec_time
line_sep
vi_mode
char
)
# export SPACESHIP_USER_SHOW=false
# export SPACESHIP_HOST_SHOW=false
export SPACESHIP_BATTERY_SHOW=false
# export SPACESHIP_TIME_SHOW=false
# export SPACESHIP_EXEC_TIME_SHOW=false
export ZSH_THEME="spaceship"
# Syntax highlighting bundle.
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_USE_ASYNC=1
antigen bundle zsh-users/zsh-history-substring-search
# Keep syntax highlighting as the last plugin
antigen bundle zdharma-continuum/fast-syntax-highlighting
# Tell Antigen that you're done.
antigen apply
bindkey -v
zstyle ':completion:*' menu select
zmodload zsh/complist
# Use vim keys in tab complete menu:
bindkey -M menuselect 'j' vi-backward-char
bindkey -M menuselect 'k' vi-down-line-or-history
bindkey -M menuselect 'l' vi-up-line-or-history
bindkey -M menuselect ';' vi-forward-char
# Add bindings to the vicmd keymap
bindkey -a 'j' backward-char
bindkey -a 'k' down-history
bindkey -a 'l' up-history
bindkey -a ';' forward-char
bindkey -a 'h' vi-repeat-find
bindkey -M visual 'j' backward-char
bindkey -M visual ';' forward-char
bindkey -a "^h" backward-delete-char
bindkey -a "^w" backward-delete-word
bindkey "^h" backward-delete-char
bindkey "^w" backward-delete-word
bindkey -a "^a" beginning-of-line
bindkey -a "^e" end-of-line
bindkey "^a" beginning-of-line
bindkey "^e" end-of-line
bindkey "^p" up-line-or-history
bindkey "^n" down-line-or-history
bindkey -a "^d" delete-char
bindkey "^d" delete-char
spaceship_vi_mode_enable
# Auto-completion
# ---------------
[[ $- == *i* ]] && source "$HOME/.vim/plugged/fzf/shell/completion.zsh" 2> /dev/null
# Key bindings
# ------------
source "$HOME/.vim/plugged/fzf/shell/key-bindings.zsh"
fi
export DISABLE_MAGIC_FUNCTIONS=true