-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zsh1
250 lines (205 loc) · 7.17 KB
/
.zsh1
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
#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
# Function for finding strings in files
fif() {
findr --type f $1 | xargs grep -n -i $2
}
# Source zshrc and backup
sourceZsh() {
source ~/.zshrc
backupToDrive ~/.zshrc
echo "New .zshrc sourced."
}
# Edit zshrc and backup
editZsh() {
updateYadm
nano ~/.zshrc
source ~/.zshrc
backupToDrive ~/.zshrc
echo "New .zshrc sourced."
}
# Update yadm
updateYadm() {
yadm pull
}
# Backup to drive
backupToDrive() {
yadm add ~/.zshrc
yadm commit -m "updated .zshrc"
yadm push
echo "New .zshrc backed up to yadm."
}
# Keybindings
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
# Aliases and environment settings
alias grep='grep --color=always -i'
export GREP_COLOR='7;33;34'
alias get='wget -m -np -c -U "eye01" -R "index.html*"'
# Word and search settings
export WORDCHARS='*?[]~&;!$%^<>'
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
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q'
preexec() { echo -ne '\e[5 q'; }
# 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]))")"
}
# 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
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
export ZPLUG_HOME=$HOME/.zplug
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
# Self-manage zplug
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
# 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=()'
# Install and load those plugins
zplug check || zplug install
zplug load
# Returning command and folder completion when line is empty
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
# 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 "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?";}'