diff options
Diffstat (limited to 'alias.sh')
-rw-r--r-- | alias.sh | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/alias.sh b/alias.sh new file mode 100644 index 0000000..2cd5285 --- /dev/null +++ b/alias.sh | |||
@@ -0,0 +1,210 @@ | |||
1 | # settings | ||
2 | alias al="vim $SETTING_DIR/$0 && source ~/$0" | ||
3 | alias all="source ~/$0" | ||
4 | alias bashrc='vim ~/.bashrc && source ~/.bashrc' | ||
5 | alias zshrc='vim ~/.zshrc && source ~/.zshrc' | ||
6 | alias vimrc='vim ~/.vimrc' | ||
7 | alias tigrc="vim $SETTING_DIR/tigrc" | ||
8 | alias gitconfig='vim ~/.gitconfig' | ||
9 | alias log='cat log | grep "`date +"%b %d"`"' | ||
10 | |||
11 | # vim | ||
12 | alias v='vim' | ||
13 | alias vv='vim ~/vimwiki/index.md' | ||
14 | wiki() { | ||
15 | cat ~/vimwiki/$1.md | ||
16 | } | ||
17 | alias ve='vim ~/.vim_runtime/my_configs.vim' | ||
18 | alias vr='vim -R' | ||
19 | alias cdv='cd ~/.vim_runtime' # amix/vimrc repo | ||
20 | |||
21 | # shell | ||
22 | alias src="source $HOME/.$(basename $SHELL)rc" | ||
23 | alias ll='ls -alh' | ||
24 | alias ai='sudo apt install' # apt install | ||
25 | alias si='sudo snap install' # snap install | ||
26 | alias ni='sudo npm install -g' # nodejs install | ||
27 | alias ss='sudo !!' | ||
28 | alias hg='history|grep' | ||
29 | alias rr='move_to_tmp' | ||
30 | move_to_tmp() { | ||
31 | mv $1 /tmp | ||
32 | } | ||
33 | |||
34 | # cd to DIRs | ||
35 | alias ..='cd ..' | ||
36 | alias ld='cd -' # last directory | ||
37 | alias cdg='cd ~/git' | ||
38 | alias cdd='cd ~/Downloads' | ||
39 | alias cdD='cd ~/Documents' | ||
40 | alias cdV='cd ~/Videos' | ||
41 | alias cdP='cd ~/Pictures' | ||
42 | |||
43 | # about custom settings | ||
44 | alias cds='cd $SETTING_DIR' | ||
45 | alias cdss='cd $SETTING_DIR/scripts' | ||
46 | alias chs='cd $SETTING_DIR && tig status' # check setting changes | ||
47 | |||
48 | # about vimwiki | ||
49 | alias cdw='cd ~/vimwiki' | ||
50 | alias chw='cd ~/vimwiki && tig' | ||
51 | alias ww='cd ~/vimwiki && git add * && git commit -am "update" && git push' | ||
52 | |||
53 | # crontab | ||
54 | alias ce='crontab -e' | ||
55 | |||
56 | # ranger | ||
57 | alias r='_ranger-cd' | ||
58 | alias ranrc='vim ~/.config/ranger/rc.conf' | ||
59 | _ranger-cd() { | ||
60 | tempfile="$(mktemp -t tmp.XXXXXX)" | ||
61 | ranger --choosedir="$tempfile" "${@:-$(pwd)}" | ||
62 | test -f "$tempfile" && | ||
63 | if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then | ||
64 | cd -- "$(cat "$tempfile")" | ||
65 | fi | ||
66 | rm -f -- "$tempfile" | ||
67 | } | ||
68 | |||
69 | # disk | ||
70 | alias df='df -h' | ||
71 | |||
72 | # git | ||
73 | alias gc='git clone' | ||
74 | alias gc1='git clone --depth=1' | ||
75 | gcg() { | ||
76 | git clone git@github.com:$1/$2.git | ||
77 | } | ||
78 | alias gls='git log -S' | ||
79 | alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule | ||
80 | |||
81 | # docker | ||
82 | alias dp='docker ps' | ||
83 | alias dpa='docker ps -a' | ||
84 | alias di='docker images' | ||
85 | alias dc='docker-compose run --rm' | ||
86 | alias dstop='docker stop' | ||
87 | alias ds='docker stop' | ||
88 | alias drm='docker rm' | ||
89 | |||
90 | # ssh | ||
91 | alias keygen='ssh-keygen -t rsa -C "typebrook@gmail.com"' | ||
92 | alias topo='ssh typebrook@topo.tw' | ||
93 | alias ptt='ssh bbsu@ptt.cc' | ||
94 | alias geothings='ssh geothings@geobingan.info' | ||
95 | alias geothings-test='ssh geothings@test.geothings.tw' | ||
96 | |||
97 | # tig | ||
98 | alias cdt='cd ~/git/tig' | ||
99 | alias t='tig' | ||
100 | alias ts='tig status' | ||
101 | alias ta='tig --all' | ||
102 | alias get-tig='curl -LO https://github.com/typebrook/tig/releases/download/tig-2.4.1/tig' | ||
103 | alias upload-tig="$SETTING_DIR/scripts/upload-github-release-asset.sh github_api_token=$(head -1 $SETTING_DIR/tokens/github-release) owner=typebrook repo=tig tag=tig-2.4.1 filename=$(which tig)" | ||
104 | |||
105 | # Android | ||
106 | alias debug='./gradlew app:installDebug && adb shell am start -n com.geothings.geobingan/.MainActivity_' | ||
107 | alias adb-default='adb shell dumpsys package domain-preferred-apps' | ||
108 | alias adb-list='adb shell dumpsys package d' | ||
109 | alias rmcache='rm -rf ~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/*' | ||
110 | alias adb-last-screenshot='adb pull /sdcard/Screenshots/`adb shell ls -t /sdcard/Screenshots/ | head -1` ~/Desktop' | ||
111 | alias adb-push='adb push /sdcard/Download/' | ||
112 | |||
113 | # gist | ||
114 | gist_list=~/gist/gist.list | ||
115 | alias gl='nl $gist_list' | ||
116 | alias gll='gist -l > $gist_list && nl $gist_list' | ||
117 | alias gi='_gistRead' | ||
118 | alias gd='_gistDelete' | ||
119 | _gistRead() { | ||
120 | gist -r $(awk '{print $1}' $gist_list | awk -v row="$1" -F '/' 'FNR==row {print $NF}') $2 | ||
121 | } | ||
122 | _gistDelete() { | ||
123 | deleted=~/gist/deleted/$(date +"%s") | ||
124 | _gistRead $1 > $deleted && echo "backup at $deleted" | ||
125 | gist --delete $(awk '{print $1}' $gist_list | awk -v row="$1" -F '/' 'FNR==row {print $NF}') && \ | ||
126 | gll | ||
127 | } | ||
128 | |||
129 | # curl | ||
130 | alias co='curl -O' | ||
131 | alias curl.code='curl -o /dev/null --silent -Iw "%{http_code}"' | ||
132 | |||
133 | # python | ||
134 | alias pip3='python3 -m pip' | ||
135 | |||
136 | # gdal | ||
137 | alias oo='ogr2ogr' | ||
138 | alias oi='ogrinfo' | ||
139 | alias oias='ogrinfo -al -so' | ||
140 | |||
141 | # sample file | ||
142 | alias sample-gpx='curl -O https://docs.mapbox.com/help/data/run.gpx' | ||
143 | alias sample-geojson='curl -O https://docs.mapbox.com/help/data/stations.geojson' | ||
144 | alias sample-geotiff='curl -O https://docs.mapbox.com/help/data/landsat.tif' | ||
145 | alias sample-csv='curl -O https://docs.mapbox.com/help/data/airports.csv' | ||
146 | alias sample-svg='curl -O https://docs.mapbox.com/help/data/bicycle-24.svg' | ||
147 | alias sample-mbtiles='curl -O https://docs.mapbox.com/help/data/trails.mbtiles' | ||
148 | alias sample-kml='curl -O https://docs.mapbox.com/help/data/farmers_markets.kml' | ||
149 | |||
150 | # data file | ||
151 | alias taiwan='curl -O http://download.geofabrik.de/asia/taiwan-latest.osm.pbf' | ||
152 | alias data-taiwan-town='curl -o town.zip -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=CD02C824-45C5-48C8-B631-98B205A2E35A' | ||
153 | alias data-taiwan-village='curl -o village.zip -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=B8AF344F-B5C6-4642-AF46-1832054399CE' | ||
154 | alias data-rudymap='curl -O https://raw.githubusercontent.com/alpha-rudy/taiwan-topo/master/styles/mapsforge_style/MOI_OSM.xml' | ||
155 | alias data-osm-diff="curl https://planet.openstreetmap.org/replication/minute/state.txt |\ | ||
156 | sed -n 2p | cut -d'=' -f2 | sed -r 's/(.{1})(.{3})/00\1\/\2\//' |\ | ||
157 | xargs -I {} echo -e https://planet.openstreetmap.org/replication/minute/'{}'.osc.gz |\ | ||
158 | xargs curl -O" | ||
159 | |||
160 | # clipboard | ||
161 | alias xi='xsel -ib' | ||
162 | alias xo='xsel -ob' | ||
163 | alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && xsel -ob ' | ||
164 | alias xll='xo >> ~/vimwiki/working.md' | ||
165 | alias xc='xsel -ob | gcc -xc -' | ||
166 | |||
167 | # image | ||
168 | vertical() { | ||
169 | convert $@ -append output.png | ||
170 | } | ||
171 | |||
172 | # misc | ||
173 | alias gr='_grepString' | ||
174 | _grepString() { | ||
175 | grep -R $1 . | ||
176 | } | ||
177 | alias findn='find . -iname' | ||
178 | alias wcl='wc -l' | ||
179 | alias x='xdg-open' | ||
180 | alias f='free -h' | ||
181 | alias yl='youtube-dl' | ||
182 | alias yla='youtube-dl -x --audio-format mp3' | ||
183 | alias raw='echo "https://raw.githubusercontent.com" | xsel -ib && xsel -ob' | ||
184 | alias editor='select-editor' | ||
185 | alias hp='http-prompt' | ||
186 | alias clocg='cloc --vcs=git' | ||
187 | alias tma='tmux a' | ||
188 | alias mm='mkvmerge -o out.webm -w 01.webm + 02.webm' | ||
189 | alias du='ncdu' | ||
190 | alias we='weechat' | ||
191 | mvt_decode() { | ||
192 | python3 $SETTING_DIR/scripts/mvt_decode.py $1 | tr \' \" | sed 's/True/true/g' | jq . | ||
193 | } | ||
194 | big52utf8() { | ||
195 | iconv -f BIG-5 -t UTF-8 $1 > $1.utf8 | ||
196 | } | ||
197 | |||
198 | # tmp | ||
199 | alias cdo='cd ~/git/openmaptiles' | ||
200 | alias cdoo='cd ~/git/openmaptiles/styles/outdoor' | ||
201 | alias cdS='cd ~/git/StreetComplete' | ||
202 | alias cdW='cd ~/git/geoBingAnWeb' | ||
203 | alias and='cd ~/git/geoBingAn.Android' | ||
204 | alias cdG='cd ~/git/git' | ||
205 | alias cdp='cd ~/git/parse-style' | ||
206 | alias cdand='cd ~/git/sample' | ||
207 | |||
208 | repo='git@github.com' | ||
209 | hub='https://github.com' | ||
210 | typebrook='git@github.com:typebrook' | ||