aboutsummaryrefslogtreecommitdiffhomepage
path: root/alias
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-11-07 10:58:29 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-11-07 10:58:29 +0800
commit0f098771b18d6d6525fc771bd85c822ab89365f0 (patch)
treed24e13431b3790c2f8832e1ae74d135c3d96a001 /alias
parent03e2ddb836f71189872a6465b4b83e8af7fa3131 (diff)
Update
Diffstat (limited to 'alias')
-rw-r--r--alias501
1 files changed, 236 insertions, 265 deletions
diff --git a/alias b/alias
index 2415d91..7b93dd4 100644
--- a/alias
+++ b/alias
@@ -1,142 +1,42 @@
1# My alias for bash and zsh 1# My alias for bash and zsh
2 2
3# __CONFIG__
4# __NETWORK__
5# __VIM__
6# __SSH__
7# __IMAP__
8# __GIST__
9# __UNIX__
10# __PACMAN__
11# __CD__
12# __BLOG__
13# __GIT__
14# __GITHUB__
15# __TIG__
16
17# __CONFIG__
18alias al="$EDITOR $SETTING_DIR/alias && source $SETTING_DIR/alias" 3alias al="$EDITOR $SETTING_DIR/alias && source $SETTING_DIR/alias"
4
5# SHELL {{{
19eval "${shell}rc(){ 6eval "${shell}rc(){
20 local RCFILE=$XDG_CONFIG_HOME/${shell}/.${shell}rc 7 local RCFILE=$XDG_CONFIG_HOME/${shell}/.${shell}rc
21 vim \$RCFILE && source \$RCFILE 8 vim \$RCFILE && source \$RCFILE
22}" 9}"
23alias vimrc='vim ~/.vimrc'
24alias tigrc="$EDITOR ~/.tigrc"
25alias mutt.rc="$EDITOR ~/.config/mutt/muttrc"
26alias ala.rc="$EDITOR ~/.config/alacritty/alacritty.toml"
27alias alacritty.rc="$EDITOR ~/.config/alacritty/alacritty.toml"
28alias git.config="$EDITOR ~/.gitconfig"
29alias gpg.config="$EDITOR ~/.gnupg/gpg-agent.conf"
30alias ssh.config="$EDITOR ~/.ssh/config"
31alias ssh.auth="$EDITOR ~/.ssh/authorized_keys"
32alias ssh.known="$EDITOR ~/.ssh/known_hosts"
33config(){ cd ~/.config/$1; }
34alias tmux.config="$EDITOR ~/.tmux.conf"
35cde() { cd /etc/$@; }
36
37alias cdetc='cde'
38alias ls='ls --color'
39alias lsd='ls -d */'
40alias grep='grep --color'
41alias eof='IGNOREEOF=10' 10alias eof='IGNOREEOF=10'
42 11
43# __NETWORK__ 12# }}}
44alias dig.detail='dig +noall +answer +multiline' 13# CUSTOM HELPER {{{
45 14cdh() { cd $SETTING_DIR/$@; }
46# __VIM__ 15alias chh="tig -C $SETTING_DIR status"
47if which nvim &>/dev/null; then 16# }}}
48 alias vim='nvim' 17# Text Encode/Decode{{{
49 alias v='nvim' 18big52utf8() {
50 alias vv='/usr/bin/vim' 19 iconv -f BIG-5 -t UTF-8
51else
52 alias v='vim'
53fi
54alias vu='vim -u NONE'
55alias vr='vim -R'
56# Edit last file
57alias vl="vim -c 'norm '"
58# Use Telescope to select recent files
59vll() { vim -c 'Telescope oldfiles'; }
60# Apply defaut session
61alias vS="vim -S /tmp/vim.session"
62alias cdv='cd ~/.config/nvim'
63vs() { which $1 && vim $(which $1); }
64[ "$shell" = zsh ] && compdef vs=which
65alias vim.dos2unix="vim '+set ff=unix' '+x'"
66
67# __SSH__
68alias cdssh='cd ~/.ssh'
69alias ptt='ssh ptt'
70alias sshv='ssh -t vps'
71ssh.tar() {
72 prompt-vim "tar cf - foo | ssh vps 'cd ~/Downloads; tar xf -' \nssh vps 'tar czf - --directory=/working/path target' | tar xvzf -"
73}
74ssh.up() {
75 set -o pipefail
76 filename=${3:-`basename $1`}
77 # Upload to absolution path
78 if [[ $2 =~ '^/' ]]; then
79 folder=${2%/}
80 cat $1 | ssh vps "mkdir -p $folder; cat >${folder}/${filename}" || return 1
81 echo Uploaded to ${folder}/${filename}
82 # Upload to relative in ~/public/
83 else
84 folder='~/public/'${2%/}
85 cat $1 | ssh vps "mkdir -p $folder; cat >${folder}/${filename}" || return 1
86 echo https://topo.tw/p/${2%/}/${filename}
87 fi
88}
89ssh.up.today() {
90 DATE=$(date --iso-8601)
91 ssh vps mkdir -p ~/public/$DATE
92 ssh.up $1 $DATE
93}
94ssh.down() {
95 ssh -t vps rm -rf -i ~/public/"$1"
96}
97
98# __IMAP__
99imap.save() {
100 curl "imaps://mail.topo.tw/$1" \
101 --user pham:`pass mail/pham@mail.topo.tw` \
102 -T $2
103}
104imap.save_attachment() {
105 #TEMPFILE=$(mktemp)
106 trap 'rm $TEMPFILE' EXIT
107 mail -a $1 -Sexpandaddr /dev/stdout | \
108 curl imaps://mail.topo.tw/INBOX \
109 --user pham:`pass mail/pham@mail.topo.tw` \
110 -T /dev/stdin
111} 20}
112imap.search.subject() { 21utf82big5() {
113 curl "imaps://mail.topo.tw/$1" \ 22 iconv -t BIG-5 -f UTF-8
114 --user pham:`pass mail/pham@mail.topo.tw` \
115 --request "SEARCH SUBJECT $2"
116} 23}
117imap.fetch() { 24urlencode() {
118 curl "imaps://mail.topo.tw/$1;MAILINDEX=$2" \ 25 perl -lpe 's/([^A-Za-z0-9.\/:])/sprintf("%%%02X", ord($1))/seg'
119 --user pham:`pass mail/pham@mail.topo.tw` | \ 26 # Alternative:
120 dos2unix | \ 27 # curl -Gso /dev/null -w %{url_effective} --data-urlencode @- ""
121 sed -E '0,/^ *$/d'
122} 28}
123 29# }}}
124# __GIST__ 30# UNIX {{{
125alias g='gist'
126alias gl='gist last'
127unalias gg &>/dev/null
128alias gg='gist grep'
129
130# __UNIX__
131alias chx='chmod +x' 31alias chx='chmod +x'
132alias chr='chmod +r' 32alias chr='chmod +r'
33config(){ cd ~/.config/$1; }
133alias k='kill %1' 34alias k='kill %1'
134alias s='sudo systemctl' 35alias s='sudo systemctl'
135alias j='sudo journalctl -xeu' 36alias j='sudo journalctl -xeu'
136alias m='mutt' 37alias ls='ls --color'
137alias h='himalaya' 38alias lsd='ls -d */'
138alias gmail="mutt -F $SETTING_DIR/mutt/muttrc.gmail" 39alias grep='grep --color'
139alias ntu="mutt -F $SETTING_DIR/mutt/muttrc.b97602041"
140path() { echo $PATH; } # Should not use alias, because $PATH is not initialized 40path() { echo $PATH; } # Should not use alias, because $PATH is not initialized
141ps1.swap() { 41ps1.swap() {
142 if [ -z "$PS1_bak" ]; then PS1_bak="$PS1" 42 if [ -z "$PS1_bak" ]; then PS1_bak="$PS1"
@@ -211,8 +111,105 @@ gr() {
211 grep -IR $@ . | sed '/^.\{2048\}./d' 111 grep -IR $@ . | sed '/^.\{2048\}./d'
212} 112}
213alias findn='find . -iname' 113alias findn='find . -iname'
114alias ce='crontab -e'
115alias cl='crontab -l'
116alias df='df -h'
214 117
215# __PACMAN__ 118# }}}
119# Clipboard{{{
120alias xi='xsel -ib'
121alias xii='`fc -ln -1` | head -1 | xsel -ib'
122alias xo='xsel -ob'
123alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && echo Copied to clipboard && xsel -ob'
124# }}}
125# TMUX {{{
126alias tma='tmux a'
127alias tmux.config="$EDITOR ~/.tmux.conf"
128# }}}
129# NETWORK {{{
130
131alias dig.detail='dig +noall +answer +multiline'
132alias co='curl -O'
133alias curl.code='curl -o /dev/null --silent -Iw "%{http_code}"'
134alias p8='ping -c 3 8.8.8.8'
135alias curl.google='curl -v google.com'
136alias curl.wifi='curl -I google.com | grep -E "^Location:" | cut -d" " -f2 | xsel -ib'
137ip.neigh() {
138 INTERFACES=$(ifconfig | sed -nE 's/^([^ :]+).*$/\1/p')
139 test -z "$1" && echo $INTERFACES && return 0
140
141 ifconfig | sed -nE "/^${1}/,/^$/ s/^ +inet ([0-9.]+) .*$/\1/p"
142}
143
144# }}}
145# MAIL {{{
146alias m='mutt'
147alias mutt.rc="$EDITOR ~/.config/mutt/muttrc"
148alias h='himalaya'
149alias gmail="mutt -F $SETTING_DIR/mutt/muttrc.gmail"
150alias ntu="mutt -F $SETTING_DIR/mutt/muttrc.b97602041"
151imap.save() {
152 curl "imaps://mail.topo.tw/$1" \
153 --user pham:`pass mail/pham@mail.topo.tw` \
154 -T $2
155}
156imap.save_attachment() {
157 #TEMPFILE=$(mktemp)
158 trap 'rm $TEMPFILE' EXIT
159 mail -a $1 -Sexpandaddr /dev/stdout | \
160 curl imaps://mail.topo.tw/INBOX \
161 --user pham:`pass mail/pham@mail.topo.tw` \
162 -T /dev/stdin
163}
164imap.search.subject() {
165 curl "imaps://mail.topo.tw/$1" \
166 --user pham:`pass mail/pham@mail.topo.tw` \
167 --request "SEARCH SUBJECT $2"
168}
169imap.fetch() {
170 curl "imaps://mail.topo.tw/$1;MAILINDEX=$2" \
171 --user pham:`pass mail/pham@mail.topo.tw` | \
172 dos2unix | \
173 sed -E '0,/^ *$/d'
174}
175
176# }}}
177# SSH {{{
178alias ssh.config="$EDITOR ~/.ssh/config"
179alias ssh.auth="$EDITOR ~/.ssh/authorized_keys"
180alias ssh.known="$EDITOR ~/.ssh/known_hosts"
181alias cdssh='cd ~/.ssh'
182alias ptt='ssh ptt'
183alias sshv='ssh -t vps'
184ssh.tar() {
185 prompt-vim "tar cf - foo | ssh vps 'cd ~/Downloads; tar xf -' \nssh vps 'tar czf - --directory=/working/path target' | tar xvzf -"
186}
187ssh.up() {
188 set -o pipefail
189 filename=${3:-`basename $1`}
190 # Upload to absolution path
191 if [[ $2 =~ '^/' ]]; then
192 folder=${2%/}
193 cat $1 | ssh vps "mkdir -p $folder; cat >${folder}/${filename}" || return 1
194 echo Uploaded to ${folder}/${filename}
195 # Upload to relative in ~/public/
196 else
197 folder='~/public/'${2%/}
198 cat $1 | ssh vps "mkdir -p $folder; cat >${folder}/${filename}" || return 1
199 echo https://topo.tw/p/${2%/}/${filename}
200 fi
201}
202ssh.up.today() {
203 DATE=$(date --iso-8601)
204 ssh vps mkdir -p ~/public/$DATE
205 ssh.up $1 $DATE
206}
207ssh.down() {
208 ssh -t vps rm -rf -i ~/public/"$1"
209}
210
211# }}}
212# PACMAN {{{
216alias pac='sudo pacman -S' # pacman install 213alias pac='sudo pacman -S' # pacman install
217alias psy='sudo pacman -Syy' 214alias psy='sudo pacman -Syy'
218alias ys='yay -S' 215alias ys='yay -S'
@@ -238,15 +235,50 @@ psi() {
238} 235}
239pkgbuild() { git clone https://aur.archlinux.org/$1.git; } 236pkgbuild() { git clone https://aur.archlinux.org/$1.git; }
240 237
241# __CD__ 238# }}}
239# Alacritty{{{
240alias ala.rc="$EDITOR ~/.config/alacritty/alacritty.toml"
241alias alacritty.rc="$EDITOR ~/.config/alacritty/alacritty.toml"
242# }}}
243# VIM {{{
244alias vimrc='vim ~/.vimrc'
245if which nvim &>/dev/null; then
246 alias vim='nvim'
247 alias v='nvim'
248 alias vv='/usr/bin/vim'
249else
250 alias v='vim'
251fi
252alias vu='vim -u NONE'
253alias vr='vim -R'
254# Edit last file
255alias vl="vim -c 'norm '"
256# Use Telescope to select recent files
257vll() { vim -c 'Telescope oldfiles'; }
258# Apply defaut session
259alias vS="vim -S /tmp/vim.session"
260alias cdv='cd ~/.config/nvim'
261vs() { which $1 && vim $(which $1); }
262[ "$shell" = zsh ] && compdef vs=which
263alias vim.dos2unix="vim '+set ff=unix' '+x'"
264vvv() {
265 while true; do
266 vim -c 'norm '
267 if [ $? -ne 0 ]; then
268 break
269 fi
270 echo "restarting vim...";
271 done
272}
273
274# }}}
275# CD {{{
242alias ..='cd ..' 276alias ..='cd ..'
243alias ...='cd ../..' 277alias ...='cd ../..'
244alias ld='cd -' # last directory 278alias ld='cd -' # last directory
245cdg() {
246 target=$(sed 's# #/#g' <<<"$@")
247 cd ~/git/$target || cd ~/git
248}
249alias cda='mkdir -p ~/data && cd ~/data' 279alias cda='mkdir -p ~/data && cd ~/data'
280cde() { cd /etc/$@; }
281alias cdetc='cde'
250alias cdd='cd ~/Downloads' 282alias cdd='cd ~/Downloads'
251alias cdD='cd ~/Documents' 283alias cdD='cd ~/Documents'
252alias cdP='cd ~/Pictures' 284alias cdP='cd ~/Pictures'
@@ -254,7 +286,8 @@ alias cdpu='cd ~/public'
254alias cdV='cd ~/Videos' 286alias cdV='cd ~/Videos'
255alias cdM='cd ~/Music' 287alias cdM='cd ~/Music'
256 288
257# __BLOG__ 289# }}}
290# BLOG {{{
258alias cdb='cd ~/blog' 291alias cdb='cd ~/blog'
259vp() { 292vp() {
260 [[ $HOST = vultr ]] || PREFIX='ssh -qt vps' 293 [[ $HOST = vultr ]] || PREFIX='ssh -qt vps'
@@ -282,19 +315,48 @@ vp() {
282 fi 315 fi
283} 316}
284 317
285# __GIT__ 318# }}}
319# GIT {{{
320alias git.config="$EDITOR ~/.gitconfig"
286unalias gc &> /dev/null # override zsh plugin alias 321unalias gc &> /dev/null # override zsh plugin alias
287gc() { git clone $@; if [ $# = 1 ]; then cd $(basename ${1%.git}); fi } 322gc() { git clone $@; if [ $# = 1 ]; then cd $(basename ${1%.git}); fi }
288gc1() { git clone --depth=1 $1 && cd $(basename $1); } 323gc1() { git clone --depth=1 $1 && cd $(basename $1); }
289gcv() { gc vps:$1; }
290alias gls='git log -S' 324alias gls='git log -S'
325cdg() {
326 target=$(sed 's# #/#g' <<<"$@")
327 cd ~/git/$target || cd ~/git
328}
291alias cdgg='cd $(git rev-parse --show-toplevel)' 329alias cdgg='cd $(git rev-parse --show-toplevel)'
292alias cdgw='cdgg && cd .github/workflows' 330alias cdgw='cdgg && cd .github/workflows'
293alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule 331alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule
294alias ch="/home/pham/helper/bin/git/check-repos.sh" 332alias ch="/home/pham/helper/bin/git/check-repos.sh"
295alias git.check="/home/pham/helper/bin/git/check-repos.sh" 333alias git.check="/home/pham/helper/bin/git/check-repos.sh"
296 334
297# __GITHUB__ 335# }}}
336# TIG {{{
337alias cdt='cd ~/git/tig'
338alias t='tig'
339alias ts='tig status'
340alias tigrc="$EDITOR ~/.tigrc"
341alias ta='tig --all'
342upload_tig() {
343 github-release.sh \
344 github_api_token=$GITHUB_API_TOKEN \
345 repo=typebrook/tig \
346 tag=LATEST \
347 type=asset \
348 filename=$(which tig)
349 action=overwrite
350}
351# }}}
352# GIST {{{
353alias g='gist'
354alias gl='gist last'
355unalias gg &>/dev/null
356alias gg='gist grep'
357
358# }}}
359# Service: GITHUB {{{
298export GITHUB_API='https://api.github.com' 360export GITHUB_API='https://api.github.com'
299export GITHUB_API_TOKEN="~/.ssh/tokens/github 2>/dev/null)" 361export GITHUB_API_TOKEN="~/.ssh/tokens/github 2>/dev/null)"
300alias hub="GITHUB_TOKEN=$GITHUB_API_TOKEN hub" 362alias hub="GITHUB_TOKEN=$GITHUB_API_TOKEN hub"
@@ -319,49 +381,12 @@ github.raw() {
319 curl -O https://raw.githubusercontent.com/$1/$2/$3 381 curl -O https://raw.githubusercontent.com/$1/$2/$3
320} 382}
321 383
322# __TIG__ 384# }}}
323alias cdt='cd ~/git/tig' 385# Beancount{{{
324alias t='tig'
325alias ts='tig status'
326alias ta='tig --all'
327upload_tig() {
328 github-release.sh \
329 github_api_token=$GITHUB_API_TOKEN \
330 repo=typebrook/tig \
331 tag=LATEST \
332 type=asset \
333 filename=$(which tig)
334 action=overwrite
335}
336
337# about custom settings
338cdh() { cd $SETTING_DIR/$@; }
339alias chh="tig -C $SETTING_DIR status"
340
341# about beancount
342alias cdB='cd $HOME/bean' 386alias cdB='cd $HOME/bean'
343alias b='vim $HOME/bean/main.bean' 387alias b='vim $HOME/bean/main.bean'
344 388# }}}
345# crontab 389# Docker{{{
346alias ce='crontab -e'
347alias cl='crontab -l'
348
349# lf
350alias r='_lf_cd'
351alias l='_lf_cd'
352_lf_cd() {
353 tempfile=$(mktemp -t tmp.XXXXXX)
354 lf --last-dir-path $tempfile
355
356 test -f "$tempfile" && \
357 cd -- "$(cat "$tempfile")" && \
358 rm -f -- "$tempfile"
359}
360
361# disk
362alias df='df -h'
363
364# docker
365alias dk='docker' 390alias dk='docker'
366alias dc='docker-compose' 391alias dc='docker-compose'
367alias dis='docker images' 392alias dis='docker images'
@@ -370,8 +395,8 @@ alias dpsa='docker ps -a'
370docker.sh() { docker run --rm -it --entrypoint /bin/sh $@; } 395docker.sh() { docker run --rm -it --entrypoint /bin/sh $@; }
371docker.bash() { docker run --rm -it --entrypoint /bin/bash $@; } 396docker.bash() { docker run --rm -it --entrypoint /bin/bash $@; }
372docker.tags() { curl -s -S "https://registry.hub.docker.com/v2/repositories/$@/tags/" | tee /dev/tty | jq '.results[]["name"]' | sort; } 397docker.tags() { curl -s -S "https://registry.hub.docker.com/v2/repositories/$@/tags/" | tee /dev/tty | jq '.results[]["name"]' | sort; }
373 398# }}}
374# Android 399# Android{{{
375alias debug='./gradlew app:installDebug && adb shell am start -n com.geothings.geobingan/.MainActivity_' 400alias debug='./gradlew app:installDebug && adb shell am start -n com.geothings.geobingan/.MainActivity_'
376alias adb.view='adb shell am start -a android.intent.action.VIEW -d' 401alias adb.view='adb shell am start -a android.intent.action.VIEW -d'
377alias adb.default='adb shell dumpsys package domain-preferred-apps' 402alias adb.default='adb shell dumpsys package domain-preferred-apps'
@@ -384,19 +409,11 @@ alias adb.input='adb shell input text'
384adb.push() { 409adb.push() {
385 adb push $1 /sdcard/Download 410 adb push $1 /sdcard/Download
386} 411}
387 412# }}}
388# curl 413# python{{{
389alias co='curl -O'
390alias curl.code='curl -o /dev/null --silent -Iw "%{http_code}"'
391
392# python
393alias pip3='python3 -m pip' 414alias pip3='python3 -m pip'
394 415# }}}
395# gdal 416# sample file{{{
396alias oo='ogr2ogr'
397alias oi='ogrinfo -al -so'
398
399# sample file
400alias sample.text='curl http://metaphorpsum.com/paragraphs/3/5' 417alias sample.text='curl http://metaphorpsum.com/paragraphs/3/5'
401alias sample.gpx='curl -O https://docs.mapbox.com/help/data/run.gpx' 418alias sample.gpx='curl -O https://docs.mapbox.com/help/data/run.gpx'
402alias sample.geojson='curl -O https://docs.mapbox.com/help/data/stations.geojson' 419alias sample.geojson='curl -O https://docs.mapbox.com/help/data/stations.geojson'
@@ -428,8 +445,8 @@ taiwan_dem() {
428 xargs curl -Lo taiwan_dem.zip 445 xargs curl -Lo taiwan_dem.zip
429 unzip -p taiwan_dem.zip dem_20m.tif >20m.tif 446 unzip -p taiwan_dem.zip dem_20m.tif >20m.tif
430} 447}
431 448# }}}
432# data file 449# DATA (from internet){{{
433alias taiwan='curl -O http://download.geofabrik.de/asia/taiwan-latest.osm.pbf' 450alias taiwan='curl -O http://download.geofabrik.de/asia/taiwan-latest.osm.pbf'
434alias data.rudymap='curl -O https://raw.githubusercontent.com/alpha-rudy/taiwan-topo/master/styles/mapsforge_style/MOI_OSM.xml' 451alias data.rudymap='curl -O https://raw.githubusercontent.com/alpha-rudy/taiwan-topo/master/styles/mapsforge_style/MOI_OSM.xml'
435alias data.rudymap_ele='curl -O http://moi.kcwu.csie.org/osm_elevations/ele_taiwan_10_50_100_500_marker-2019.7.o5m' 452alias data.rudymap_ele='curl -O http://moi.kcwu.csie.org/osm_elevations/ele_taiwan_10_50_100_500_marker-2019.7.o5m'
@@ -450,32 +467,36 @@ alias data.taiwan_town='curl -o town.zip -L https://data.moi.gov.tw/MoiOD/Syste
450alias data.taiwan_village='curl -o village.zip -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=B8AF344F-B5C6-4642-AF46-1832054399CE' 467alias data.taiwan_village='curl -o village.zip -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=B8AF344F-B5C6-4642-AF46-1832054399CE'
451alias data.taiwan_poly='curl -O http://download.geofabrik.de/asia/taiwan.poly' 468alias data.taiwan_poly='curl -O http://download.geofabrik.de/asia/taiwan.poly'
452alias data.taiwan_county_code='curl --silent https://www.ris.gov.tw/documents/data/5/1/RSCD0101.txt | iconv -f BIG-5 -t UTF-8 -' 469alias data.taiwan_county_code='curl --silent https://www.ris.gov.tw/documents/data/5/1/RSCD0101.txt | iconv -f BIG-5 -t UTF-8 -'
470# }}}
471# PASS {{{
453 472
454# clipboard 473alias chp='tig -C ~/.password-store'
455alias xi='xsel -ib' 474alias chpass='tig -C ~/.password-store'
456alias xii='`fc -ln -1` | head -1 | xsel -ib' 475alias cdpass='cd ~/.password-store'
457alias xo='xsel -ob' 476alias p='pass'
458alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && echo Copied to clipboard && xsel -ob' 477alias pc='pass -c'
459 478alias pe='pass edit'
460# Text Encode/Decode 479alias pgn='pass generate --in-place --clip'
461big52utf8() { 480alias pgc='pass generate --clip'
462 iconv -f BIG-5 -t UTF-8 481words() {
463} 482 cat /usr/share/dict/usa | grep -E "^[a-z]{4,8}$" | shuf | head -40 | xargs -n${1:-2}
464utf82big5() {
465 iconv -t BIG-5 -f UTF-8
466}
467urlencode() {
468 perl -lpe 's/([^A-Za-z0-9.\/:])/sprintf("%%%02X", ord($1))/seg'
469 # Alternative:
470 # curl -Gso /dev/null -w %{url_effective} --data-urlencode @- ""
471} 483}
472 484
473# Network 485# }}}
474alias p8='ping -c 3 8.8.8.8' 486# Nginx{{{
475alias curl.google='curl -v google.com' 487alias vgx='sudo vim /etc/nginx/sites-enabled/vps && sudo nginx -t && sudo systemctl reload nginx'
476alias curl.wifi='curl -I google.com | grep -E "^Location:" | cut -d" " -f2 | xsel -ib' 488alias cdngx='cd /etc/nginx'
477 489# }}}
478# misc 490# GIS {{{
491alias oo='ogr2ogr'
492alias oi='ogrinfo -al -so'
493TAIWAN_BBOX='118.1036,20.72799,122.9312,26.60305'
494TAIWAN_BBOX_V='20.72799,118.1036,26.60305,122.9312'
495TAIPEI_BBOX='121.346,24.926,121.676,25.209'
496TAIPEI_BBOX_V='24.926,121.346,25.209,121.676'
497# }}}
498# Misc{{{
499alias gpg.config="$EDITOR ~/.gnupg/gpg-agent.conf"
479alias foo='echo bar > foo && echo File foo is created && ls -lh foo' 500alias foo='echo bar > foo && echo File foo is created && ls -lh foo'
480alias bar='echo foo > bar && echo File bar is created && ls -lh bar' 501alias bar='echo foo > bar && echo File bar is created && ls -lh bar'
481alias wcl='wc -l' 502alias wcl='wc -l'
@@ -488,7 +509,6 @@ yt.audio() {
488alias editor='select-editor' 509alias editor='select-editor'
489alias hp='http-prompt' 510alias hp='http-prompt'
490alias clocg='cloc --vcs=git' 511alias clocg='cloc --vcs=git'
491alias tma='tmux a'
492pbf() { 512pbf() {
493 protoc --decode_raw 513 protoc --decode_raw
494} 514}
@@ -508,25 +528,8 @@ wrap2geojson() { jq -s '{ type: "FeatureCollection", features: . }'; }
508alias cdtrash='cd ~/.local/share/Trash' 528alias cdtrash='cd ~/.local/share/Trash'
509trash() { mv $@ ~/.local/share/Trash; } 529trash() { mv $@ ~/.local/share/Trash; }
510alias ge='graph-easy --boxart' 530alias ge='graph-easy --boxart'
511 531# }}}
512# pass 532# tmp{{{
513alias chp='tig -C ~/.password-store'
514alias chpass='tig -C ~/.password-store'
515alias cdpass='cd ~/.password-store'
516alias p='pass'
517alias pc='pass -c'
518alias pe='pass edit'
519alias pgn='pass generate --in-place --clip'
520alias pgc='pass generate --clip'
521words() {
522 cat /usr/share/dict/usa | grep -E "^[a-z]{4,8}$" | shuf | head -40 | xargs -n${1:-2}
523}
524
525# Nginx
526alias vgx='sudo vim /etc/nginx/sites-enabled/vps && sudo nginx -t && sudo systemctl reload nginx'
527alias cdngx='cd /etc/nginx'
528
529# tmp
530alias stew='cd ~/git/mapstew' 533alias stew='cd ~/git/mapstew'
531alias vc='vultr-cli' 534alias vc='vultr-cli'
532alias xkb='cd $SETTING_DIR && make xkb' 535alias xkb='cd $SETTING_DIR && make xkb'
@@ -538,36 +541,4 @@ alias md='reveal'
538alias terminal.color='printf "\e[%dm%d dark\e[0m \e[%d;1m%d bold\e[0m\n" {30..37}{,,,}' 541alias terminal.color='printf "\e[%dm%d dark\e[0m \e[%d;1m%d bold\e[0m\n" {30..37}{,,,}'
539alias gpg.bye='gpg-connect-agent reloadagent /bye' 542alias gpg.bye='gpg-connect-agent reloadagent /bye'
540alias npm='pnpm' 543alias npm='pnpm'
541 544# }}}
542# GIS
543TAIWAN_BBOX='118.1036,20.72799,122.9312,26.60305'
544TAIWAN_BBOX_V='20.72799,118.1036,26.60305,122.9312'
545TAIPEI_BBOX='121.346,24.926,121.676,25.209'
546TAIPEI_BBOX_V='24.926,121.346,25.209,121.676'
547
548# Comment out
549#alias mm='mkvmerge -o out.webm -w 01.webm + 02.webm'
550#alias we='weechat'
551
552LOCAL_ALIAS=~/.config/local.alias
553alias allo="$EDITOR $LOCAL_ALIAS && source $LOCAL_ALIAS"
554if [ -e $LOCAL_ALIAS ]; then
555 source $LOCAL_ALIAS
556fi
557
558vvv() {
559 while true; do
560 vim -c 'norm '
561 if [ $? -ne 0 ]; then
562 break
563 fi
564 echo "restarting vim...";
565 done
566}
567
568ip.neigh() {
569 INTERFACES=$(ifconfig | sed -nE 's/^([^ :]+).*$/\1/p')
570 test -z "$1" && echo $INTERFACES && return 0
571
572 ifconfig | sed -nE "/^${1}/,/^$/ s/^ +inet ([0-9.]+) .*$/\1/p"
573}