/
zshrc_arch
385 lines (333 loc) · 11.9 KB
/
zshrc_arch
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
autoload -U compinit colors vcs_info
colors
compinit
# Report command running time if it is more than 3 seconds
REPORTTIME=3
# Keep a lot of history
HISTFILE=~/.zsh_history
HISTSIZE=5000
SAVEHIST=5000
# Add commands to history as they are entered, don't wait for shell to exit
setopt INC_APPEND_HISTORY
# Do not keep duplicate commands in history
setopt HIST_IGNORE_ALL_DUPS
# Do not remember commands that start with a whitespace
setopt HIST_IGNORE_SPACE
# Correct spelling of all arguments in the command line
setopt CORRECT_ALL
# Enable autocompletion
zstyle ':completion:*' completer _complete _correct _approximate
# PROMPT STYLE
#zstyle ':vcs_info:*' stagedstr '%F{green}●%f'
#zstyle ':vcs_info:*' unstagedstr '%F{yellow}●%f'
#zstyle ':vcs_info:git:*' check-for-changes true
#zstyle ':vcs_info:git*' formats "%F{green}[%f%F{cyan}%b%f %u%c%F{green}]%f "
zstyle ':vcs_info:git*' formats "%F{green}[%f%F{cyan}%b%f%F{green}]%f "
_setup_ps1() {
vcs_info
GLYPH="☁"
[ "x$KEYMAP" = "xvicmd" ] && GLYPH="▼"
PS1=" %(?.%F{blue}.%F{red})$GLYPH%f %(1j.%F{cyan}[%j]%f .)%F{green}%1~%f %(!.%F{red}#%f .)$vcs_info_msg_0_"
#RPROMPT="$vcs_info_msg_0_"
}
_setup_ps1
# Vi mode
zle-keymap-select () {
_setup_ps1
zle reset-prompt
}
zle -N zle-keymap-select
zle-line-init () {
zle -K viins
}
zle -N zle-line-init
bindkey -v
export PATH="$PATH:$HOME/.local/bin"
export PATH=/usr/sbin:$PATH
export PATH=/usr/local/bin:$PATH
export LANG="en_US.utf8"
export LANGUAGE="en_US.utf8"
export LC_ALL="en_US.utf8"
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
export TERMINAL="kitty"
export BROWSER="qutebrowser"
export READER="zathura"
export EDITOR="nvim"
export FILE="ranger"
export PAGER=most man ls
export BAT_PAGER=less
export ONI_NEOVIM_PATH="/home/marius/.local/bin/nvim"
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar
export SUDO_ASKPASS=/usr/bin/ssh-askpass
export PASSWORD_STORE_ENABLE_EXTENSIONS=true
export GIT_SSH_VARIANT=ssh
export NVIM_COC_LOG_FILE=coc.log
#export XDG_RUNTIME_DIR=/tmp
#export PYTHONPATH="$HOME/osm2city"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
[ -f ~/dotfiles/my-fzf.zsh ] && source ~/dotfiles/my-fzf.zsh
### color output for many commands
if [[ "$TERM" != dumb ]] && (( $+commands[grc] )) ; then
# Supported commands
cmds=(
cc \
configure \
cvs \
df \
diff \
dig \
gcc \
gmake \
ifconfig \
last \
ldap \
ls \
make \
mount \
mtr \
netstat \
ping \
ping6 \
ps \
traceroute \
traceroute6 \
wdiff \
whois \
iwconfig \
);
# Set alias for available commands.
for cmd in $cmds ; do
if (( $+commands[$cmd] )) ; then
alias $cmd="grc --colour=auto $(whence $cmd)"
fi
done
# Clean up variables
unset cmds cmd
fi
######################
### Custom Aliases ###
######################
alias ..='cd ..' # Go up one directory
alias ...='cd ../..' # Go up two directories
alias ....='cd ../../..' # Go up three directories
alias -- -='cd -' # Go back
alias k='clear'
alias bc='bc -l -q'
alias h='history'
alias myip="curl ipinfo.io/ip"
alias tm='cd ~/Sync/tmuxp && tmuxp load'
alias v='nvim'
alias lynx='lx'
alias cat='bat --theme GitHub'
alias ping='prettyping --nolegend'
alias find='/usr/bin/fd'
alias mpv='mpv --hwdec=auto'
#alias st='stterm -f "Iosevka Term:size=18"'
# privileged access
if [ $UID -ne 0 ]; then
alias svim='sudo nvim'
alias reboot='sudo reboot'
alias shutdown='sudo shutdown -h now'
alias off='sudo shutdown -h now'
alias upgrade='sudo pacman -Syuw & sudo pacman -Syu'
alias update=''
alias purge='yay -Rns '
alias uninstall='yay -Rs '
alias install='yay -S '
#Alias to remove orphaned packages
alias orphan='sudo pacman -Rsn $(pacman -Qqdt)'
alias root='sudo su'
alias _='sudo'
fi
#OTHERS
alias mysql='mysql --auto-rehash --auto-vertical-output'
alias meteo='curl wttr.in/Ghimbav'
alias cutremur='curl https://secure.geonames.org/earthquakesJSON\?north\=48.26\&south\=43.62\&east\=29.71\&west\=20.26\&date\='2020-06-04'\&username=sica07 | jq ".earthquakes[0]"'
alias alias-edit='nvim ~/.zshrc'
alias g='git'
alias r='ranger'
alias d='docker'
alias dc='docker compose'
alias todo='nvim -o ~/MEGA/vimwiki/{todo.txt,doing.txt,done.txt}';
alias n='nvim ~/MEGA/vimwiki/Scratch.md';
alias today='bat --theme TwoDark -p --language swift -r 1:10 ~/MEGA/vimwiki/todo.txt';
alias space='duf --sort size'
alias du='duf --sort size'
alias help='tldr'
alias wallpaper="feh --recursive --randomize --bg-fill '/home/marius/Sync/Desktoppr/' &"
alias moon="feh --bg-fill '/home/marius/Sync/Desktoppr/moon50k.png'"
alias pig='ping google.ro'
alias fboff="sudo -- sh -c -e 'echo '127.0.0.1' facebook.com >> /etc/hosts'"
alias fbon="sudo -- sh -c -e 'sed --in-place '/facebook/d' /etc/hosts'"
alias imginfo="identify -format 'Name: %f Dimensions: %P Type: %m'"
alias rg='rg --color always'
alias rgi='rg --no-ignore'
alias rgc='rg -C 5'
alias rgci='rg -C 5 --no-ignore'
alias memTop='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10'
alias cpuTop='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
alias tetris='bastet'
alias snake='nsnake'
alias tron='ssh sshtron.zachlatta.com'
alias ww='nvim -c VimwikiIndex'
url="https://wol.jw.org/ro/wol/dt/r34/lp-m/"
today=$(date "+%Y/%m/%d")
alias dt='w3m $url$today'
alias portainer='sudo docker run -d -p 7800:8000 -p 7900:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce'
alias peggo='youtube-dl -x --audio-quality 0 --audio-format mp3 --embed-thumbnail --metadata-from-title "%(artist)s - %(title)s"'
alias mobi='kindlegen'
alias random='shuf -n 1 -i'
alias phpr='psysh'
alias phpsh='psysh'
alias dropboxu="rclone sync ~/Sync/vimwiki dropbox:Apps/vimwiki"
alias t='~/dotfiles/scripts/t.sh'
alias ztl='~/dotfiles/scripts/ztl.sh'
alias dl='~/dotfiles/scripts/dailylogs.sh'
#NF will always point to the newest file/directory in that current folder
#e.g. tar xf NF //untar the newest file
alias -g NF='./*(oc[1])'
alias -s git='git clone'
alias -s {jpg,jpeg,png}='feh -x -. -d --draw-exif --draw-tinted -B "black"'
alias -s pdf='zathura'
alias -s {mp4,mp3,flac,ogg,wav}='mpv'
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
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
alias ls="exa --icons"
alias la="exa --icons -la"
alias ll="exa --icons -l"
alias '?'="duck"
alias rescue="env -u SESSION_MANAGER rescuetime &"
alias kanban="cd ~/Sync/vimwiki && nvim -O {todo,doing,done}.txt"
alias abi='ssh -t abi "tmux a -t 0"'
# FUNCTIONS
function kil {
kill -SIGTERM $(pidof $1)
}
## JUMP functionality
export MARKPATH=$HOME/.marks
function j {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
}
function unmark {
rm -i "$MARKPATH/$1"
}
function marks {
ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
}
function _completemarks {
reply=($(ls $MARKPATH))
}
## clockify scripts
function clk {
curl --data "{\"start\": \"$(date -u +"%Y-%m-%dT%TZ")\", \"description\":\"$1\"}" -H "content-type: application/json" -H "X-Api-Key: X8fZTAMwBgJQNJGU" -X POST https://api.clockify.me/api/v1/workspaces/5ec9089187cbcc1ab7f15b3b/time-entries | jq
}
function clks {
curl --data "{\"end\": \"$(date -u +"%Y-%m-%dT%TZ")\"}" -H "content-type: application/json" -H "X-Api-Key: X8fZTAMwBgJQNJGU" -X PATCH https://api.clockify.me/api/v1/workspaces/5ec9089187cbcc1ab7f15b3b/user/5ec9089187cbcc1ab7f15b3a/time-entries | jq
}
function report {
curl --data "start=$(date -u +"%Y-%m-%dT00:00:00Z")&hydrated=true" --get -H "content-type: application/json" -H "X-Api-Key: X8fZTAMwBgJQNJGU" -X GET https://api.clockify.me/api/v1/workspaces/5ec9089187cbcc1ab7f15b3b/user/5ec9089187cbcc1ab7f15b3a/time-entries | jq '.[] | {project: .project.name, title: .description, duration: .timeInterval.duration} '
}
# Start a PHP server from a directory, optionally specifying the port
# (Requires PHP 5.4.0+.)
function phpserver() {
local port="${1:-4000}"
local ip=$(ipconfig getifaddr en0)
sleep 2 && open "http://${ip}:${port}/" &
php -S "${ip}:${port}"
}
# Search on duckduckgo
function duck() {
lx "https://lite.duckduckgo.com/lite?kd=-1&kp=-1&q=$*"
}
function gg() {
lx "https://lite.duckduckgo.com/lite?kd=-1&kp=-1&q=!g $*"
}
function so() {
lx "https://lite.duckduckgo.com/lite?kd=-1&kp=-1&q=!so $*"
}
function w() {
lx "https://lite.duckduckgo.com/lite?kd=-1&kp=-1&q=!w $*"
}
function k() {
lx "https://lite.duckduckgo.com/lite?kd=-1&kp=-1&q=!php $*"
}
# Docker
function dssh() {
docker exec -it "$@" bash
}
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$@"
}
# Make a pdf look like scanned
function xerox() {
convert -density 150 "$@" -colorspace gray -blur 0x0.1 -sharpen 0x5.0 -level 10%,90% -rotate -0.5 -sharpen 0x1.2 xerox.pdf
}
function pdftojpg() {
convert -density 600 "$@" planificare.jpg
}
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-9000}"
sleep 2 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
function lx() {
lynxpath=/usr/bin/lynx
[[ ! -x $lynxpath ]] && lynxpath=/usr/local/bin/lynx
useragent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.79 Safari/537.1 Lynx"
if [ -e "$HOME/.config/lynx/lynx.cfg" ];then
export LYNX_CFG="$HOME/.config/lynx/lynx.cfg"
fi
if [ -e "$HOME/.config/lynx/lynx.lss" ];then
export LYNX_LSS="$HOME/.config/lynx/lynx.lss"
fi
if [ ! -x "$lynxpath" ]; then
echo "Doesn't look like lynx is installed."
exit 1
fi
exec "$lynxpath" --useragent="$useragent" -accept_all_cookies "$@"
}
## Use keep.sh to transfer files
transfer() { if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;return 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -e "$file" ];then echo "$file: No such file or directory">&2;return 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,;else cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;}
copy(){
cat | xclip -selection clipboard
}
paste(){
xclip -selection clipboard -o
}
# create a Zettelkasten note
zet(){
nvim "+Zet $*"
}
#find in files with fzf
f() {
local file
file=$(rg "$*" --color never -n . | fzf) && nvim -c $(echo "/$*") +$(echo $file | /usr/bin/cut -d':' -f2) $(echo $file | /usr/bin/cut -d':' -f1)
}
timer() {
runtime="$@ minute"
endtime=$(date -ud "$runtime" +%s)
echo "Starting the $@ minutes timer..."
notify-send -a "Timer" "Starting the $@ minutes timer..."
while [[ $(date -u +%s) -le $endtime ]]
do
sleep 1m
done
echo "The $@ minutes time is up!"
notify-send -a "Timer" "The $@ minutes time is up!"
mpv /usr/share/sounds/Fresh_and_Clean/stereo/system-ready.ogg
}
compctl -K _completemarks jump
compctl -K _completemarks unmark
source ~/.local/bin/antigen.zsh
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen apply