aboutsummaryrefslogtreecommitdiffhomepage
path: root/alias
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2022-05-27 12:44:27 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2022-05-27 12:44:27 +0800
commit6532894e80e06f665de0845a9465b09ea6d2099e (patch)
tree8baf24df896dd3fe37e5464271a7631d1bc23c1b /alias
parentcbfe5fe7130de8fa9383e80cb883dc3a5b8c52ef (diff)
Update
Diffstat (limited to 'alias')
-rw-r--r--alias87
1 files changed, 42 insertions, 45 deletions
diff --git a/alias b/alias
index 3cf1371..eceedcc 100644
--- a/alias
+++ b/alias
@@ -95,26 +95,26 @@ prompt() {
95 rm $TMPFILE 95 rm $TMPFILE
96} 96}
97file.sort() { 97file.sort() {
98 find $1 -type f -print0 |\ 98 find $1 -type f -print0 |\
99 xargs -0 ls --sort=size -lh |\ 99 xargs -0 ls --sort=size -lh |\
100 head -20 100 head -20
101} 101}
102file.size() { 102file.size() {
103 find $1 -type f -print0 |\ 103 find $1 -type f -print0 |\
104 xargs -0 ls -l |\ 104 xargs -0 ls -l |\
105 awk '{ n=int(log($5)/log(2)); 105 awk '{ n=int(log($5)/log(2));
106 if (n<10) n=10; 106 if (n<10) n=10;
107 size[n]++ } 107 size[n]++ }
108 END { for (i in size) printf("%d %d\n", 2^i, size[i]) 108 END { for (i in size) printf("%d %d\n", 2^i, size[i])
109 }' |\ 109 }' |\
110 sort -n |\ 110 sort -n |\
111 awk 'function human(x) { x[1]/=1024; if (x[1]>=1024) { x[2]++; human(x) }} 111 awk 'function human(x) { x[1]/=1024; if (x[1]>=1024) { x[2]++; human(x) }}
112 { 112 {
113 a[1]=$1; 113 a[1]=$1;
114 a[2]=0; 114 a[2]=0;
115 human(a); 115 human(a);
116 printf("%3d%s: %6d\n", a[1],substr("kMGTEPYZ",a[2]+1,1),$2) 116 printf("%3d%s: %6d\n", a[1],substr("kMGTEPYZ",a[2]+1,1),$2)
117 }' 117 }'
118} 118}
119highlight() { grep --color -E "$1|\$"; } 119highlight() { grep --color -E "$1|\$"; }
120 120
@@ -186,16 +186,17 @@ alias cdgg='cd $(git rev-parse --show-toplevel)'
186alias cdgw='cdgg && cd .github/workflows' 186alias cdgw='cdgg && cd .github/workflows'
187alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule 187alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule
188check_repo() { 188check_repo() {
189 cd $1 2>/dev/null || return 0 189 cd $1 2>/dev/null || return 0
190 echo check $1 190 echo check $1
191 git status -s 191 git status -s
192 [[ -n $(git cherry origin) ]] 2>/dev/null && print "\e[31m[ahead]\e[0m" 192 [[ -n $(git cherry origin) ]] 2>/dev/null && print "\e[31m[ahead]\e[0m"
193} 193}
194check() { 194check() {
195 check_repo $SETTING_DIR 195 check_repo $SETTING_DIR
196 check_repo $HOME/.password-store 196 check_repo $HOME/.password-store
197 check_repo $HOME/vimwiki 197 check_repo $HOME/vimwiki
198 check_repo $HOME/.task 198 check_repo $HOME/.task
199 check_repo $HOME/bean
199} 200}
200alias ch='check' 201alias ch='check'
201 202
@@ -380,16 +381,16 @@ image.from_data_url() {
380 identify $1 381 identify $1
381} 382}
382image.text() { 383image.text() {
383 convert \ 384 convert \
384 -size 230x130 \ 385 -size 230x130 \
385 -background lightblue \ 386 -background lightblue \
386 -font Noto-Sans-Bold \ 387 -font Noto-Sans-Bold \
387 -pointsize 25 \ 388 -pointsize 25 \
388 -fill black \ 389 -fill black \
389 -gravity Center \ 390 -gravity Center \
390 caption:"${1:=foo}" \ 391 caption:"${1:=foo}" \
391 -flatten \ 392 -flatten \
392 "${2:=foo}".jpg 393 "${2:=foo}".jpg
393} 394}
394 395
395# Reset clock 396# Reset clock
@@ -446,13 +447,9 @@ urlencode() {
446bak() { 447bak() {
447 cp $1 $1.bak 448 cp $1 $1.bak
448} 449}
449wrap2geojson() { 450wrap2geojson() { jq -s '{ type: "FeatureCollection", features: . }'; }
450 jq -s '{ type: "FeatureCollection", features: . }'
451}
452alias cdtrash='cd ~/.local/share/Trash' 451alias cdtrash='cd ~/.local/share/Trash'
453trash() { 452trash() { mv $@ ~/.local/share/Trash; }
454 mv $@ ~/.local/share/Trash
455}
456 453
457# task 454# task
458alias tk='task' 455alias tk='task'
@@ -470,11 +467,11 @@ tt() {
470 467
471# upload with 0x0.st 468# upload with 0x0.st
472up() { 469up() {
473 curl -F"file=@${1}" http://0x0.st 470 curl -F"file=@${1}" http://0x0.st
474 #curl -F "file=@${1}" https://api.anonfiles.com/upload 471 #curl -F "file=@${1}" https://api.anonfiles.com/upload
475} 472}
476short() { 473short() {
477 curl -F"shorten=${1}" http://0x0.st 474 curl -F"shorten=${1}" http://0x0.st
478} 475}
479 476
480# pass 477# pass