-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
318 lines (256 loc) · 8.22 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
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
#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
fpath=("$HOME/.zsh.d" $fpath)
# Uncommenting this will break completion for aliases in a different way.
# When uncommented, gco will complete with files instead of branches.
#setopt complete_aliases
# Case sensitive completion
CASE_SENSITIVE=true
source $HOME/dotfiles/antigen/antigen.zsh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle command-not-found
antigen bundle vi-mode
antigen bundle extract
antigen bundle z
antigen bundle history-substring-search
antigen bundle debian
antigen bundle common-aliases
antigen bundle fzf
antigen bundle zsh-users/zsh-completions
## Load the theme.
#antigen theme romkatv/powerlevel9k powerlevel9k
# antigen theme spaceship-prompt/spaceship-prompt
# fzf-z
antigen bundle andrewferrier/fzf-z
antigen bundle ~/.zsh.d/fzf-colcon --no-local-clone
# Tell antigen that you're done.
antigen apply
export apt_pref="apt"
setopt EXTENDED_HISTORY # puts timestamps in the history
setopt INC_APPEND_HISTORY SHARE_HISTORY
setopt APPEND_HISTORY
HISTSIZE=100000000
SAVEHIST=100000000
PATH="$PATH:$HOME/bin:$HOME/.local/bin"
export PAGER="less -r"
export EDITOR="vim"
# Pager Colors
default=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 2)
purple=$(tput setaf 5)
orange=$(tput setaf 9)
# Begin blinking
export LESS_TERMCAP_mb=$red
# Begin bold
export LESS_TERMCAP_md=$orange
# End mode
export LESS_TERMCAP_me=$default
# End standout-mode
export LESS_TERMCAP_se=$default
# Begin standout-mode - info box
export LESS_TERMCAP_so=$purple
# End underline
export LESS_TERMCAP_ue=$default
# Begin underline
export LESS_TERMCAP_us=$green
# # --------------------------------------------------------------------
# # aliases
# # --------------------------------------------------------------------
alias pylab='ipython --pylab --profile=pylab'
alias pylab3='ipython3 --pylab --profile=pylab'
alias g='gvim --remote-silent'
alias trash=gvfs-trash
alias v='vim -R -'
alias agr='sudo apt-get upgrade'
alias av='apt-cache show'
alias ar="sudo $apt_pref remove"
alias duhm='du -h --max-depth=1 | sort -h'
alias duhs='du -hs * | sort -h'
alias fn='find -name'
alias ack='ack-grep'
alias vimdiff='vim -d'
alias ag='ag --path-to-ignore ~/.ignore'
alias gdb='gdb -q'
alias ign-gdb='gdb -q --args /usr/bin/ruby $(which ign)'
alias gz-gdb='gdb -q --args /usr/bin/ruby $(which gz)'
alias ign-lldb='lldb -- /usr/bin/ruby $(which ign)'
alias gz-lldb='lldb -- /usr/bin/ruby $(which gz)'
alias cgdb='cgdb -d gdb'
alias ign-cgdb='cgdb -d gdb --args /usr/bin/ruby $(which ign)'
alias ign-gdbgui='gdbgui --args /usr/bin/ruby $(which ign)'
alias ign-perf='perf record -F 99 -g -- /usr/bin/ruby $(which ign)'
alias gz-perf='perf record -F 99 -g -- /usr/bin/ruby $(which gz)'
alias gc="git commit -v -s"
alias gsw="git switch"
alias lg="lazygit"
alias lgb="lazygit branch"
# Key Bindings
bindkey "^r" history-incremental-search-backward
xp() { tmux showb | xsel -i -b }
bindkey -M viins jj vi-cmd-mode
bindkey -M viins '\e.' insert-last-word
#bindkey -M vicmd v edit-command-line
# Tmuxinator
[[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator
#RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
export PATH=$HOME/.rvm/bin:$PATH # Add RVM to PATH for scripting
# ROS
if [ -x $HOME/code/catkin_ws/devel ]; then
source $HOME/code/catkin_ws/devel/setup.zsh
export ROS_WORKSPACE=$HOME/code/catkin_ws
fi
# ccache
export PATH=/usr/lib/ccache:$PATH
#http://justin.abrah.ms/dotfiles/zsh.html
psgrep() {
if [ ! -z $1 ] ; then
ps aux | grep $1 | grep -v grep
else
echo "!! Need name to grep for"
fi
}
wll(){
ll $(which $1)
}
[[ -s /usr/share/virtualenvwrapper/virtualenvwrapper.sh ]] && source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
#export FZF_DEFAULT_COMMAND='ag -g ""'
export FZF_DEFAULT_COMMAND='fdfind'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_COMPLETION_TRIGGER='~~'
#bindkey '^I' $fzf_default_completion
#bindkey '^I' $fzf_default_completion
export FZFZ_EXCLUDE_PATTERN="\.(git|hg)"
export FZFZ_SUBDIR_LIMIT=10
# This makes a big difference
export FZFZ_EXTRA_OPTS="-e"
#revgitpr() {
# if [[ ! -z $1 ]] ; then
# if [[ ! -z $2 ]] ; then
# if [[ ! -z $3 ]] ; then
# #hg status --change $(echo $3 | awk '{print $NF}') | grep -v ^\? >> $2
# else
# git diff --name-status $1... >> $2
# fi
# fi
# if [[ ! -z $3 ]] ; then
# vim -c "ALEDisable | set diffopt-=iwhite | DiffReview $3"
# else
# vim -c "ALEDisable | set diffopt-=iwhite | DiffReview git diff $1..."
# fi
# else
# echo "Need branch to diff against and path to PR review file"
# fi
#}
revgitpr() {
if [[ ! -z $1 ]] ; then
gh pr diff | lsdiff --strip 1 -s >> $1
fi
#$HOME/code/neovim-diff/install/bin/nvim -c "PRReviewMode| DiffReview gh pr diff"
vim -c "PRReviewMode| DiffReview gh pr diff"
}
revgitbranch() {
#$HOME/code/neovim-diff/install/bin/nvim -c "PRReviewMode | DiffReview git diff $1..."
vim -c "PRReviewMode | DiffReview git diff $1..."
}
# Setup revgitpr to use git branch completion
compdef "_git_cmd_update -r" revgitbranch
_fzf_complete_revgitbranch() {
_fzf_complete "--no-sort" "$@" < <( { git branch -a})
}
nmmangled() {
if [[ ! -z $2 ]] ; then
spat=$(nm -C $1 | grep $2 | cut -f1 -d ' ')
nm $1 | grep -F $spat
else
nm $1
fi
}
ign-test() {
# get the name of project
builddir=$(catkin locate -b)
pkg=$(catkin list --this -u)
pushd -q $builddir/$pkg
make test
popd -q
#catkin build --this -iv --no-deps --make-args test
}
ign-source() {
source $(catkin locate -d)/setup.zsh
}
gencatkincompdb() {
# This assumes the compile_commands.json has already been generated in the build directory
local build_dir=$(catkin locate -b)
local pkg=$(catkin list --this -u)
compdb -p $build_dir/$pkg list > compile_commands.json
}
_find_colcon_root_dir(){
# Look for build/.built_by while crawling up each directory
local curDir=$PWD
local rc=1;
while true
do
if [[ -d "$curDir/build" && -e "$curDir/build/.built_by" ]] then
local built_by=$(cat $curDir/build/.built_by)
if [[ $built_by == "colcon" ]] then
echo "$curDir"
rc=0
break
fi
elif [[ $curDir == "/" ]] then
break
else
curDir=$(dirname $curDir)
fi
done
return $rc
}
gencolconcompdb() {
local root_dir=$(_find_colcon_root_dir)
if [[ $? -eq 0 ]] then
local pkg=$(colcon --log-base /dev/null list -n --paths $PWD)
local pkg_build_dir="$root_dir/build/$pkg"
if [[ ! -e "$pkg_build_dir/compile_commands.json" ]] then
cmake $pkg_build_dir -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
fi
compdb -p $pkg_build_dir list > compile_commands.json
fi
}
dv() {
vi +"DiffviewOpen -uno $1"
}
# Setup dv to use git branch completion
# compdef "_git_cmd_update -r" dv
# _fzf_complete_dv() {
# _fzf_complete "--no-sort" "$@" < <( { git branch -a})
# }
#export NVM_DIR="$HOME/.nvm"
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
export DEBEMAIL="[email protected]"
export DEBFULLNAME="Addisu Z. Taddese"
zle -N fzf-colcon-dir-widget
bindkey -M viins -r '^F'
bindkey -M vicmd -r '^F'
bindkey -M emacs -r '^F'
bindkey -M viins '^F' fzf-colcon-dir-widget
bindkey -M vicmd '^F' fzf-colcon-dir-widget
bindkey -M emacs '^F' fzf-colcon-dir-widget
eval "$(starship init zsh)"
# Enable docker to autocomplete with after cli flags.
# See https://github.com/ohmyzsh/ohmyzsh/issues/9266
zstyle ':completion:*:*:docker:*' option-stacking yes
zstyle ':completion:*:*:docker-*:*' option-stacking yes
gz_last_release_version() {
git describe --tags --abbrev=0 | sed 's/.*_//'
}
export LANG=${LANG:-"en_US.UTF-8"}
export LC_ALL=${LC_ALL:-"en_US.UTF-8"}