blob: 34e3876f4b47f4d7fa1cc74676354403d24182e0 (
plain)
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
|
#! /bin/sh
# settings
alias al="vim $SETTING_DIR/alias && source $SETTING_DIR/alias"
alias all="source $SETTING_DIR/alias"
alias zshrc="vim ~/.zshrc && source ~/.$(basename $SHELL)rc"
alias bashrc="vim ~/.bashrc && source ~/.$(basename $SHELL)rc"
alias vimrc='vim ~/.vimrc'
alias tigrc="vim $SETTING_DIR/tigrc"
alias gitconfig='vim ~/.gitconfig'
alias log="cat $SETTING_DIR/log | grep '`date +'%b %d'`'"
# vim
alias v='vim'
alias vv='vim ~/vimwiki/index.md'
alias ve='vim ~/.vim_runtime/my_configs.vim'
alias vr='vim -R'
alias cdv='cd ~/.vim_runtime' # amix/vimrc repo
function vs() {
vim $(which $1)
}
# shell
alias src="source $HOME/.$(basename $SHELL)rc"
alias ll='ls -alh'
alias si='sudo snap install' # snap install
alias ni='sudo npm install -g' # nodejs install
alias ss='sudo !!'
alias hg='history|grep'
alias rmrf='rm -rf'
alias rr='move_to_tmp'
function move_to_tmp() {
mv $@ /tmp
}
# package
alias ai='sudo apt install' # apt install
alias aptu='sudo apt update && sudo apt upgrade'
# cd to DIRs
alias ..='cd ..'
alias ld='cd -' # last directory
function cdg(){
cd ~/git/$1
}
alias cdgg='cd ~/git/gist'
alias cda='cd ~/data'
alias cdd='cd ~/Downloads'
alias cdD='cd ~/Documents'
alias cdV='cd ~/Videos'
alias cdP='cd ~/Pictures'
# about custom settings
alias cds='cd $SETTING_DIR'
alias cdss='cd $SETTING_DIR/scripts'
alias chs='cd $SETTING_DIR && tig status' # check setting changes
# about vimwiki
alias cdw='cd ~/vimwiki'
alias chw='cd ~/vimwiki && tig --all'
alias ww='cd ~/vimwiki && git add * && git commit -am "update" && git push'
function wg() {
vim ~/vimwiki/$1.md
}
function wi() {
cat ~/vimwiki/$1.md
}
# crontab
alias ce='crontab -e'
# ranger
alias r='_ranger-cd'
alias ranrc='vim ~/.config/ranger/rc.conf'
_ranger-cd() {
tempfile="$(mktemp -t tmp.XXXXXX)"
ranger --choosedir="$tempfile" "${@:-$(pwd)}"
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}
# disk
alias df='df -h'
# git
unalias gc &> /dev/null # override zsh plugin alias
function gc() {
git clone $1 && cd $(basename $1)
}
function gc1() {
git clone --depth=1 $1 && cd $(basename $1)
}
function gcg() {
git clone git@github.com:$1/$2.git && cd $(basename $2)
}
alias gls='git log -S'
alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule
# docker
alias dp='docker ps'
alias dpa='docker ps -a'
alias di='docker images'
alias dc='docker-compose run --rm'
alias ds='docker stop'
alias drm='docker rm'
alias dr='docker run --rm -it'
# ssh
alias keygen='ssh-keygen -t rsa -C "typebrook@gmail.com"'
alias topo='ssh typebrook@topo.tw'
alias ptt='ssh bbsu@ptt.cc'
alias geothings='ssh geothings@geobingan.info'
alias geothings-test='ssh geothings@test.geothings.tw'
# tig
alias cdt='cd ~/git/tig'
alias t='tig'
alias ts='tig status'
alias ta='tig --all'
alias get-tig='curl -LO https://github.com/typebrook/tig/releases/download/tig-2.5.0/tig'
function upload-tig() {
upload-github-release-asset.sh \
github_api_token=$(cat ~/settings/tokens/github) \
owner=typebrook \
repo=tig \
tag=LATEST \
filename=$(which tig)
overwrite=false
}
# Android
alias debug='./gradlew app:installDebug && adb shell am start -n com.geothings.geobingan/.MainActivity_'
alias adb-default='adb shell dumpsys package domain-preferred-apps'
alias adb-list='adb shell dumpsys package d'
alias rmcache='rm -rf ~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/*'
alias adb-last-screenshot='adb pull /sdcard/Screenshots/`adb shell ls -t /sdcard/Screenshots/ | head -1` ~/Desktop'
function adb-push() {
adb push $1 /sdcard/Download
}
# gist
gist_list=~/gist/gist.list
alias gl='nl $gist_list'
alias gll='gist -l > $gist_list && nl $gist_list'
alias gi='_gistRead'
alias gd='_gistDelete'
function _gistRead() {
gist -r $(awk '{print $1}' $gist_list | awk -v row="$1" -F '/' 'FNR==row {print $NF}') $2
}
function _gistDelete() {
deleted=~/gist/deleted/$(date +"%s")
_gistRead $1 > $deleted && echo "backup at $deleted"
gist --delete $(awk '{print $1}' $gist_list | awk -v row="$1" -F '/' 'FNR==row {print $NF}') && \
gll
}
# curl
alias co='curl -O'
alias curl.code='curl -o /dev/null --silent -Iw "%{http_code}"'
# python
alias pip3='python3 -m pip'
# gdal
alias oo='ogr2ogr'
alias oi='ogrinfo'
alias oias='ogrinfo -al -so'
# sample file
alias sample-gpx='curl -O https://docs.mapbox.com/help/data/run.gpx'
alias sample-geojson='curl -O https://docs.mapbox.com/help/data/stations.geojson'
alias sample-geotiff='curl -O https://docs.mapbox.com/help/data/landsat.tif'
alias sample-csv='curl -O https://docs.mapbox.com/help/data/airports.csv'
alias sample-svg='curl -O https://docs.mapbox.com/help/data/bicycle-24.svg'
alias sample-mbtiles='curl -O https://docs.mapbox.com/help/data/trails.mbtiles'
alias sample-kml='curl -O https://docs.mapbox.com/help/data/farmers_markets.kml'
alias sample-osm='curl https://api.openstreetmap.org/api/0.6/node/3428095932'
# data file
alias taiwan='curl -O http://download.geofabrik.de/asia/taiwan-latest.osm.pbf'
alias data-rudymap='curl -O https://raw.githubusercontent.com/alpha-rudy/taiwan-topo/master/styles/mapsforge_style/MOI_OSM.xml'
alias data-rudymap-ele='curl -O http://moi.kcwu.csie.org/osm_elevations/ele_taiwan_10_50_100_500_marker-2019.7.o5m'
alias data-osm-diff="curl https://planet.openstreetmap.org/replication/minute/state.txt |\
sed -n 2p | cut -d'=' -f2 | sed -r 's/(.{1})(.{3})/00\1\/\2\//' |\
xargs -I {} echo -e https://planet.openstreetmap.org/replication/minute/'{}'.osc.gz |\
xargs curl -O"
alias data-taiwan-town='curl -o town.zip -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=CD02C824-45C5-48C8-B631-98B205A2E35A'
alias data-taiwan-village='curl -o village.zip -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=B8AF344F-B5C6-4642-AF46-1832054399CE'
alias data-taiwan-poly='curl -O http://download.geofabrik.de/asia/taiwan.poly'
function data-taiwan-county-code() {
curl --silent https://www.ris.gov.tw/documents/data/5/1/RSCD0101.txt |\
iconv -f BIG-5 -t UTF-8 -
}
# clipboard
alias xi='xsel -ib'
alias xo='xsel -ob'
alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && xsel -ob '
alias xll='xo >> ~/vimwiki/working.md'
alias xc='xsel -ob | gcc -xc -'
# image
function image_vertical() {
convert $@ -append output.png
}
# misc
alias token="cd $SETTING_DIR/tokens && vim $SETTING_DIR/tokens"
alias gr='_grepString'
function _grepString() {
grep -R $1 .
}
alias findn='find . -iname'
alias wcl='wc -l'
alias x='xdg-open'
alias f='free -h'
alias yl='youtube-dl'
alias yla='youtube-dl -x --audio-format mp3'
alias raw='echo "https://raw.githubusercontent.com" | xsel -ib && xsel -ob'
alias editor='select-editor'
alias hp='http-prompt'
alias clocg='cloc --vcs=git'
alias tma='tmux a'
alias mm='mkvmerge -o out.webm -w 01.webm + 02.webm'
alias du='ncdu'
alias we='weechat'
function mvt_decode() {
python3 $SETTING_DIR/scripts/mvt_decode.py $1 | tr \' \" | sed 's/True/true/g' | jq .
}
function big52utf8() {
iconv -f BIG-5 -t UTF-8
}
# tmp
alias cdo='cd ~/git/openmaptiles'
alias cdS='cd ~/git/StreetComplete'
alias cdW='cd ~/git/geoBingAnWeb'
alias and='cd ~/git/geoBingAn.Android'
alias cdG='cd ~/git/git'
alias cdT='cd ~/git/taiwan-topo'
alias cdand='cd ~/git/sample'
alias cdm='cd ~/git/sharkbig.github.io'
repo='git@github.com'
hub='https://github.com'
typebrook='git@github.com:typebrook'
GITHUB_API='https://api.github.com'
|