-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.shrc
303 lines (239 loc) · 7.75 KB
/
.shrc
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
# ~/.shrc
# --------
# common bash-like rc
# environment {{{
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export LC_TIME=en_US.UTF-8
export LC_COLLATE=en_US.UTF-8
# export BROWSER=firefox
export EDITOR=nvim
export PAGER=less
export PATH=$HOME/dotfiles/bin:/usr/local/bin:$PATH
export S_COLORS=auto
# Timezone
# export TZ='America/Argentina/Buenos_Aires'
# gnu GPG agent
export GPG_AGENT_INFO_FILE=$HOME/.gnupg/gpg-agent-info
if [ -f "$GPG_AGENT_INFO_FILE" ]; then
. "$GPG_AGENT_INFO_FILE"
export GPG_TTY=$(tty)
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
fi
# java
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=gasp'
# }}}
# langs {{{
# ollama
export GIN_MODE=release
# rvm
# if [ -d "$HOME/.rvm" ]; then
# export PATH="$PATH:$HOME/.rvm/bin"
# if [ -s "$HOME/.rvm/scripts/rvm" ]; then
# source "$HOME/.rvm/scripts/rvm"
# fi
# fi
# rust
# if [ -d "$HOME/.cargo/bin" ]; then
# export PATH="$PATH:$HOME/.cargo/bin"
# fi
# php
export PATH="/opt/homebrew/opt/[email protected]/sbin:$PATH"
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
# bun completions
# # Bun
# export BUN_INSTALL="/Users/tom/.bun"
# export PATH="$BUN_INSTALL/bin:$PATH"
# [ -s "/Users/tom/.bun/_bun" ] && source "/Users/tom/.bun/_bun"
# deno
# export DENO_INSTALL="/Users/tom/.deno"
# export PATH="$DENO_INSTALL/bin:$PATH"
# kiex manages elixir version (install https://github.com/taylor/kiex)
# if [ -s "$HOME/.kiex/scripts/kiex" ]; then
# source "$HOME/.kiex/scripts/kiex"
# fi
# }}}
# macos {{{
# homebrew
if [ -r /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# ruby brew
if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
export PATH=/opt/homebrew/opt/ruby/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi
# docker use linux platform by default
export DOCKER_DEFAULT_PLATFORM=linux/amd64
# bun completions
# [ -s "/Users/tom/.bun/_bun" ] && source "/Users/tom/.bun/_bun"
# nvm
export NVM_DIR="$HOME/.nvm"
[ -d "$NVM_DIR" ] || mkdir -p "$NVM_DIR"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && . "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
# [ -f /opt/homebrew/opt/asdf/libexec/asdf.sh ] && . /opt/homebrew/opt/asdf/libexec/asdf.sh
# present slides in chromeless browser
alias present='open -n -a "Google Chrome" --args "--app=file:///Users/tom/r/slides/export/Slides/index.html"'
# }}}
# aliases {{{
alias service-mysql="docker run --name mysql-container -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 -d mysql; sleep 10; docker exec -it mysql-container mysql"
alias vim=nvim
alias vi=nvim
alias v=nvim
alias l='ls -ltra'
# alias S="sudo systemctl"
# alias gp='ps aux | grep -v grep | grep -i'
# alias lo='libreoffice'
# alias turn-off='xset -display :0.0 dpms force off'
alias en=su
alias g=git
alias GG="git commit -m u && git push"
alias listen="lsof -nP +c 15 | grep LISTEN"
alias cu='curl -w "\n"'
alias dk=docker
alias dk-rm='docker ps --filter status=dead --filter status=exited --filter status=created -aq | xargs docker rm -v'
alias dk-volume-clean="docker volume ls -qf dangling=true | xargs -r docker volume rm -v"
alias dk-image-clean="docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi"
# alias dk-umount="umount -l $(grep 'aufs' /proc/mounts | awk '{print$2}' | sort -r)"
alias k=kubectl
# alias ka="kubectl apply -f -"
# alias dk-delete-all-images="docker system prune && docker rmi -f $(docker images -a -q)"
# alias png2jpg="mkdir -p jpgs; sips -s format jpeg *.png --out \"./jpgs/\""
# nocache
# if which nocache >/dev/null 2>&1; then
# alias cp='nocache cp -i'
# alias mv='nocache mv -i'
# alias rm='nocache rm -i'
# fi
# systemctl user mode
# alias Start='systemctl --user start'
# alias Status='systemctl --user status'
# alias Stop='systemctl --user stop'
# alias Restart='systemctl --user restart'
# alias Enable='systemctl --user enable'
# alias Disable='systemctl --user disable'
# arch linux
#alias P=yay
#alias Pu="yay -Syyu"
#alias pacman-autoremove='sudo pacman -Rcns $(pacman -Qdtq)'
#alias pacman-clean='sudo pacman -Scc'
alias steam='LIBGL_DEBUG=verbose LD_PRELOAD="/usr/\$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1 /usr/$LIB/libxcb.so.1" steam'
alias whatisall='whatis $(compgen -c) | sort'
alias dice='echo $((0x$(head -c5 /dev/random|xxd -ps)%6+1))'
alias zip-parts='echo "Repairing zip volume into archive_repaired.zip" && zip --output archive_repaired.zip -F'
alias jsonvalid='python -mjson.tool'
# alias codename='code=$(curl -G http://codenames.herokuapp.com/api/codenames -d lists=adjectives,cities -d filters=alliterative,random 2>/dev/null); echo $code; echo $code | xclip -i'
# }}}
# functions {{{
# convert pdf page into high-res image
function pdfpage {
pdf="$1"
page="$2"
output="page_${page}.png"
magick -density 300 "${pdf}[${page}]" -background white -flatten "$output"
open "$output"
}
function png2jpg {
for f in "$@"; do
dest="${f%.png}.jpg"
magick "$f" "$dest"
jpegoptim --max=80 "$dest"
done
}
function gp {
ps -ef "$1" | grep -v grep
}
# add a drop shadow to an image
function dropshadow {
for f in "$@"; do
source="$f"
output="${f}.shadow"
magick "$f" \( +clone -background black -shadow 20x5+5+5 \) +swap -background white -layers merge +repage "$output"
mv "$output" "$source"
done
}
function mp3tomid {
for f in "$@"; do
mp3="$f"
wav="${f%.mp3}.wav"
midi="${f%.mp3}.mid"
echo "===> Converting $mp3 to $midi"
ffmpeg -i "$mp3" "$wav"
waon -i "$wav" -o "$midi"
done
}
function mp3towav {
for f in "$@"; do
mp3="$f"
wav="${f%.mp3}.wav"
echo "===> Converting $mp3 to $wav"
ffmpeg -i "$mp3" "$wav"
done
}
function mp4tostereo {
for f in "$@"; do
mp4="$f"
stereo="${f%.mp4}_stereo.mp4"
echo "===> Converting $mp4 to stereo"
ffmpeg -i "$mp4" -map 0:v -map 0:a -c:v h264 -c:a aac -f mp4 "$stereo"
mv "$stereo" "$mp4"
done
}
function mp4towaveform {
for f in "$@"; do
mp4="$f"
waveform="${f%.mp4}_waveform.mp4"
echo "===> Creating waveform for $mp4"
ffmpeg -i "$mp4" -filter_complex "[0:a]showwaves=mode=cline:s=hd720:colors=white[v]" -map "[v]" -map 0:a -pix_fmt yuv420p -an "$waveform"
done
}
function mp3towaveform {
for f in "$@"; do
mp3="$f"
wav="${f%.mp3}.wav"
waveform="${f%.mp3}_waveform.mp4"
ffmpeg -i "$mp3" "$wav"
echo "===> Creating waveform for $mp3"
ffmpeg -i "$mp3" -filter_complex "[0:a]showwaves=mode=cline:s=hd720:colors=white[v]" -map "[v]" -pix_fmt yuv420p "$waveform"
# ffmpeg -i "$m34" -filter_complex "[0:a]showwaves=mode=cline:s=hd720:colors=white[v]" -map "[v]" -map 0:a -pix_fmt yuv420p -an "$waveform"
done
}
function mp4tosrt {
for f in "$@"; do
mp4="$f"
wav="${f%.mp4}.wav"
ffmpeg -i "$mp4" "$wav"
echo "===> Transcribing $mp4"
whisper --language en --output_format srt "$wav"
done
}
function md2doc {
in="$1"
out="${in}.docx"
html=$(mktemp)
pandoc -f gfm -t html -o "$html" --wrap=none "$in"
pandoc -f html -t docx -o "$out" --wrap=none "$html"
rm -f "$html"
}
function md2wp {
in="$1"
out="${in}.wp"
pandoc -f gfm -t markdown_phpextra+hard_line_breaks-citations-markdown_in_html_blocks --embed-resources --wrap=none -o "$out" "$in"
}
# }}}
# enhancements {{{
# use \ to invoke the original command, eg \cat
# if which bat >/dev/null 2>&1; then
# alias cat=bat
# fi
# if which prettyping >/dev/null 2>&1; then
# alias ping=prettyping
# fi
if which htop >/dev/null 2>&1; then
alias top=htop
fi
# }}}
# vim: fdm=marker