-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
308 lines (248 loc) · 9.23 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
# 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
#source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
#################################################################
source ~/antigen.zsh
################library##################
# Load Antigen configurations
antigen init ~/.antigenrc
zstyle ':completion:*' completer _oldlist _expand _complete _ignored _match _correct _approximate _prefix
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._p3]=* r:|=*' 'l:|=* r:|=*'
zstyle :compinstall filename '/home/me/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
export HISTSIZE=10000000
export SAVEHIST=10000000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_FIND_NO_DUPS
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_BEEP # Beep when accessing nonexistent history.
setopt autocd beep extendedglob nomatch notify
bindkey -v
# End of lines configured by zsh-newuser-install
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Set any settings or overrides here
#prompt belak
#function for find strings in files
fif() {
findr --type f $1|xargs grep -n -i $2
}
sourceZsh(){
source ~/.zshrc
backupToDrive ~/.zshrc
echo "New .zshrc sourced."
}
editZsh(){
updateYadm
nano ~/.zshrc
source ~/.zshrc
backupToDrive ~/.zshrc
echo "New .zshrc sourced."
}
updateYadm() {
yadm pull
}
backupToDrive(){
yadm add ~/.zshrc
yadm commit -m "updated .zshrc"
yadm push
echo "New .zshrc backed up to yadm."
}
# Use - to go back to previous directory
#alias -- -='cd -'
# Keybindings
# Use C-x C-e to edit the current command line
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\C-x\C-e' edit-command-line
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
# [Space] - do history expansion
bindkey ' ' magic-space
# start typing + [Up-Arrow] - fuzzy find history forward
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
# start typing + [Down-Arrow] - fuzzy find history backward
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
alias grep='grep --color=always -i'
export GREP_COLOR='7;33;34'
alias get='wget -m -np -c -U "eye01" -R "index.html*" '
# By default, zsh considers many characters part of a word (e.g., _ and -).
# Narrow that down to allow easier skipping through words via M-f and M-b.
export WORDCHARS='*?[]~&;!$%^<>'
# Highlight search results in ack.
export ACK_COLOR_MATCH='red'
# vi mode
bindkey -v
export KEYTIMEOUT=1
# Use vim keys in tab complete menu:
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# Use lf to switch directories and bind it to ctrl-o
lfcd () {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp" >/dev/null
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
}
# Activate the closest virtualenv by looking in parent directories.
activate_virtualenv() {
if [ -f env/bin/activate ]; then . env/bin/activate;
elif [ -f ../env/bin/activate ]; then . ../env/bin/activate;
elif [ -f ../../env/bin/activate ]; then . ../../env/bin/activate;
elif [ -f ../../../env/bin/activate ]; then . ../../../env/bin/activate;
fi
}
# Find the directory of the named Python module.
python_module_dir () {
echo "$(python -c "import os.path as _, ${1}; \
print _.dirname(_.realpath(${1}.__file__[:-1]))"
)"
}
### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing DHARMA Initiative Plugin Manager (zdharma/zinit)…%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
export ANKI_ROBOT_SERIAL=008089cf
export ANKI_ROBOT_HOST="192.168.1.56"
export VECTOR_ROBOT_NAME=Vector-w4v1
# Load the Variables file
if [ -e ~/.zsh_files/variables.zsh ]; then
source ~/.zsh_files/variables.zsh
fi
# Load the Aliases file
if [ -e ~/.zsh_files/aliases.zsh ]; then
source ~/.zsh_files/aliases.zsh
fi
# Load the Aliases1 file
if [ -e ~/.aliases ]; then
source ~/.aliases
fi
# Load the TinyCareTerminal file
if [ -e ~/.zsh_files/tct.zsh ]; then
source ~/.zsh_files/tct.zsh
fi
# Load the Functions file
if [ -e ~/.zsh_files/functions.zsh ]; then
source ~/.zsh_files/functions.zsh
fi
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zinit-zsh/z-a-patch-dl \
zinit-zsh/z-a-as-monitor \
zinit-zsh/z-a-bin-gem-node
zplugin light zdharma/zplugin-crasis
### End of Zinit's installer chunk
export ZPLUG_HOME=$HOME/.zplug
# create fake KBUILD Information by default
export KBUILD_BUILD_USER="vera"
export KBUILD_BUILD_HOST="F.R.I.D.A.Y."
# user profile
source $HOME/.profile
# zplug initialization
[[ ! -f $ZPLUG_HOME/init.zsh ]] && git clone https://github.com/zplug/zplug $ZPLUG_HOME
source $ZPLUG_HOME/init.zsh
# do self-manage
zplug 'zplug/zplug', hook-build:'zplug --self-manage'
# load nice libs from oh-my-zsh
zplug "lib/completion", from:oh-my-zsh
zplug "lib/history", from:oh-my-zsh
zplug "lib/key-bindings", from:oh-my-zsh
zplug "lib/termsupport", from:oh-my-zsh
zplug "lib/directories", from:oh-my-zsh
zplug "plugins/nmap", from:oh-my-zsh
# for speed debug. mine ? 230ms, not bad tho
# zplug "paulmelnikow/zsh-startup-timer"
# naisu minimal theme
MNML_USER_CHAR=$USER
MNML_INSERT_CHAR='do:'
zplug 'subnixr/minimal', use:minimal.zsh, as:theme
# auto-close quotes and brackets like a pro
zplug 'hlissner/zsh-autopair', defer:2
# another eyecandy
zplug 'zdharma/fast-syntax-highlighting', defer:2, hook-load:'FAST_HIGHLIGHT=()'
# finally install and load those plugins
zplug check || zplug install
zplug load
# returning command and folder completion when line is empty
# like a bash, but better
blanktab() { [[ $#BUFFER == 0 ]] && CURSOR=3 zle list-choices || zle expand-or-complete }
zle -N blanktab && bindkey '^I' blanktab
# load my own aliases
[[ -f $HOME/.aliases ]] && source $HOME/.aliases
# finally. paint the terminal emulator!
[[ -f ~/.cache/wal/sequences ]] && (cat ~/.cache/wal/sequences &)
getnews () {
curl https://newsapi.org/v2/top-headlines -s -G \
-d sources=$1 \
-d apiKey=noapikeyforyou \
| jq '.articles[] | .title'
}
startmyday () {
echo "Good morning, ShadowHarvy."
echo "\nUpdating..."
pacui u
python3 -m pip install --user --upgrade anki_vector
echo "\nThe weather right now:"
ansiweather -l Toronto
# echo "\nNews from the BBC:"
# getnews bbc-news
# echo "\nNews from the Washington Post:"
# getnews the-washington-post
# echo "\nNews from Hacker News:"
# getnews hacker-news
}
echo "2020 12 31" | awk '{dt=mktime($0 " 00 00 00")-systime(); print "There are " int(dt/86400/7) " weeks left until the year ends. What will you do?";}'
### End of Zinit's installer chunk
### End of Zinit's installer chunk
eval "$(starship init zsh)"
(( ! ${+functions[p10k]} )) || p10k finalize