diff options
Diffstat (limited to 'alias')
| -rw-r--r-- | alias | 107 |
1 files changed, 53 insertions, 54 deletions
| @@ -39,9 +39,51 @@ urlencode() { | |||
| 39 | } | 39 | } |
| 40 | # }}} | 40 | # }}} |
| 41 | # ADMIN {{{ | 41 | # ADMIN {{{ |
| 42 | |||
| 42 | alias etc.passwd='sudo vim /etc/passwd' | 43 | alias etc.passwd='sudo vim /etc/passwd' |
| 44 | alias s='sudo systemctl' | ||
| 45 | alias j='sudo journalctl -xeu' | ||
| 46 | alias jf='sudo journalctl -xfeu' | ||
| 47 | |||
| 48 | # }}} | ||
| 49 | # Nginx{{{ | ||
| 50 | alias vgx='sudo vim /etc/nginx/sites-enabled/vps && sudo nginx -t && sudo systemctl reload nginx' | ||
| 51 | alias ng.conf='sudo vim /etc/nginx/nginx.conf' | ||
| 52 | alias ng.log='tail -f /var/log/nginx/access.log' | ||
| 53 | alias cdngx='cd /etc/nginx' | ||
| 54 | # }}} | ||
| 55 | # Web {{{ | ||
| 56 | alias www.git='/srv/git/create.sh' | ||
| 57 | alias www='make -f ~/site/www/Makefile' | ||
| 58 | alias cdwww='cd ~/site/www' | ||
| 59 | vp() { | ||
| 60 | [[ $HOST = vultr ]] || PREFIX='ssh -qt vps' | ||
| 61 | |||
| 62 | filename="${1%.md}.md" | ||
| 63 | post=$(eval $PREFIX find ~/blog/content -name $filename | head -1 | sed 's/\r//') | ||
| 64 | |||
| 65 | if [ -z "$post" ]; then | ||
| 66 | echo "sh -c 'cd ~/blog && hugo new posts/$filename'" | eval ${PREFIX} | ||
| 67 | post="~/blog/content/posts/$filename" | ||
| 68 | fi | ||
| 69 | |||
| 70 | shift | ||
| 71 | if [[ $HOST = vultr ]]; then | ||
| 72 | vim $@ "$post" | ||
| 73 | else | ||
| 74 | # Copy from vps | ||
| 75 | tmpfile=$(mktemp --suffix .md) | ||
| 76 | scp vps:"$post" $tmpfile | ||
| 77 | |||
| 78 | # Edit locally | ||
| 79 | vim $tmpfile --cmd "autocmd BufWritePost $tmpfile silent! :!setsid scp % vps:$post &" && \ | ||
| 80 | cat $tmpfile | ssh vps "cd ~/blog && cat >$post && git add $post && git commit -m 'Update with vim'" && \ | ||
| 81 | rm $tmpfile | ||
| 82 | fi | ||
| 83 | } | ||
| 43 | # }}} | 84 | # }}} |
| 44 | # UNIX {{{ | 85 | # UNIX {{{ |
| 86 | |||
| 45 | config(){ cd ~/.config/$1; } | 87 | config(){ cd ~/.config/$1; } |
| 46 | alias sound="echo -ne '\a'" | 88 | alias sound="echo -ne '\a'" |
| 47 | alias hg='history | grep' | 89 | alias hg='history | grep' |
| @@ -129,11 +171,6 @@ file.size() { | |||
| 129 | } | 171 | } |
| 130 | 172 | ||
| 131 | # }}} | 173 | # }}} |
| 132 | # Systemctl {{{ | ||
| 133 | alias s='sudo systemctl' | ||
| 134 | alias j='sudo journalctl -xeu' | ||
| 135 | alias jf='sudo journalctl -xfeu' | ||
| 136 | # }}} | ||
| 137 | # TTY {{{ | 174 | # TTY {{{ |
| 138 | alias tma='tmux a' | 175 | alias tma='tmux a' |
| 139 | alias tmux.config="$EDITOR ~/.tmux.conf" | 176 | alias tmux.config="$EDITOR ~/.tmux.conf" |
| @@ -272,6 +309,10 @@ alias xo='xsel -ob' | |||
| 272 | alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && echo Copied to clipboard && xsel -ob' | 309 | alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && echo Copied to clipboard && xsel -ob' |
| 273 | # }}} | 310 | # }}} |
| 274 | # X11: Misc {{{ | 311 | # X11: Misc {{{ |
| 312 | alias cdD='cd ~/Documents' | ||
| 313 | alias cdP='cd ~/Pictures' | ||
| 314 | alias cdV='cd ~/Videos' | ||
| 315 | alias cdM='cd ~/Music' | ||
| 275 | alias x='xdg-open' | 316 | alias x='xdg-open' |
| 276 | alias ob.rc='vim ~/.config/openbox/rc.xml' | 317 | alias ob.rc='vim ~/.config/openbox/rc.xml' |
| 277 | # }}} | 318 | # }}} |
| @@ -315,43 +356,10 @@ alias ld='cd -' # last directory | |||
| 315 | alias cda='mkdir -p ~/data && cd ~/data' | 356 | alias cda='mkdir -p ~/data && cd ~/data' |
| 316 | cde() { cd /etc/$@; } | 357 | cde() { cd /etc/$@; } |
| 317 | alias cdetc='cde' | 358 | alias cdetc='cde' |
| 318 | alias cdd='cd ~/Downloads' | ||
| 319 | alias cdD='cd ~/Documents' | ||
| 320 | alias cdP='cd ~/Pictures' | ||
| 321 | alias cdpu='cd ~/public' | 359 | alias cdpu='cd ~/public' |
| 322 | alias cdV='cd ~/Videos' | 360 | alias cdd='cd ~/Downloads' |
| 323 | alias cdM='cd ~/Music' | ||
| 324 | alias cdtrash='cd ~/.local/share/Trash' | 361 | alias cdtrash='cd ~/.local/share/Trash' |
| 325 | # }}} | 362 | # }}} |
| 326 | # website {{{ | ||
| 327 | alias cdb='cd ~/site/www' | ||
| 328 | vp() { | ||
| 329 | [[ $HOST = vultr ]] || PREFIX='ssh -qt vps' | ||
| 330 | |||
| 331 | filename="${1%.md}.md" | ||
| 332 | post=$(eval $PREFIX find ~/blog/content -name $filename | head -1 | sed 's/\r//') | ||
| 333 | |||
| 334 | if [ -z "$post" ]; then | ||
| 335 | echo "sh -c 'cd ~/blog && hugo new posts/$filename'" | eval ${PREFIX} | ||
| 336 | post="~/blog/content/posts/$filename" | ||
| 337 | fi | ||
| 338 | |||
| 339 | shift | ||
| 340 | if [[ $HOST = vultr ]]; then | ||
| 341 | vim $@ "$post" | ||
| 342 | else | ||
| 343 | # Copy from vps | ||
| 344 | tmpfile=$(mktemp --suffix .md) | ||
| 345 | scp vps:"$post" $tmpfile | ||
| 346 | |||
| 347 | # Edit locally | ||
| 348 | vim $tmpfile --cmd "autocmd BufWritePost $tmpfile silent! :!setsid scp % vps:$post &" && \ | ||
| 349 | cat $tmpfile | ssh vps "cd ~/blog && cat >$post && git add $post && git commit -m 'Update with vim'" && \ | ||
| 350 | rm $tmpfile | ||
| 351 | fi | ||
| 352 | } | ||
| 353 | |||
| 354 | # }}} | ||
| 355 | # GIT: config {{{ | 363 | # GIT: config {{{ |
| 356 | alias git.config="$EDITOR ~/.gitconfig" | 364 | alias git.config="$EDITOR ~/.gitconfig" |
| 357 | unalias gc &> /dev/null # override zsh plugin alias | 365 | unalias gc &> /dev/null # override zsh plugin alias |
| @@ -369,9 +377,6 @@ alias ch="/home/pham/helper/bin/git/check-repos.sh" | |||
| 369 | alias git.check="/home/pham/helper/bin/git/check-repos.sh" | 377 | alias git.check="/home/pham/helper/bin/git/check-repos.sh" |
| 370 | 378 | ||
| 371 | # }}} | 379 | # }}} |
| 372 | # GIT: Web {{{ | ||
| 373 | alias git.web='/srv/git/create.sh' | ||
| 374 | # }}} | ||
| 375 | # GIT: TIG {{{ | 380 | # GIT: TIG {{{ |
| 376 | alias cdt='cd ~/git/tig' | 381 | alias cdt='cd ~/git/tig' |
| 377 | alias t='tig' | 382 | alias t='tig' |
| @@ -445,13 +450,6 @@ adb.push() { | |||
| 445 | adb push $1 /sdcard/Download | 450 | adb push $1 /sdcard/Download |
| 446 | } | 451 | } |
| 447 | # }}} | 452 | # }}} |
| 448 | # Beancount{{{ | ||
| 449 | alias cdB='cd $HOME/bean' | ||
| 450 | alias b='vim $HOME/bean/main.bean' | ||
| 451 | # }}} | ||
| 452 | # python{{{ | ||
| 453 | alias pip3='python3 -m pip' | ||
| 454 | # }}} | ||
| 455 | # sample file{{{ | 453 | # sample file{{{ |
| 456 | alias foo='echo bar > foo && echo File foo is created && ls -lh foo' | 454 | alias foo='echo bar > foo && echo File foo is created && ls -lh foo' |
| 457 | alias bar='echo foo > bar && echo File bar is created && ls -lh bar' | 455 | alias bar='echo foo > bar && echo File bar is created && ls -lh bar' |
| @@ -525,11 +523,12 @@ words() { | |||
| 525 | } | 523 | } |
| 526 | 524 | ||
| 527 | # }}} | 525 | # }}} |
| 528 | # Nginx{{{ | 526 | # Beancount{{{ |
| 529 | alias vgx='sudo vim /etc/nginx/sites-enabled/vps && sudo nginx -t && sudo systemctl reload nginx' | 527 | alias cdB='cd $HOME/bean' |
| 530 | alias ng.conf='sudo vim /etc/nginx/nginx.conf' | 528 | alias b='vim $HOME/bean/main.bean' |
| 531 | alias ng.log='tail -f /var/log/nginx/access.log' | 529 | # }}} |
| 532 | alias cdngx='cd /etc/nginx' | 530 | # python{{{ |
| 531 | alias pip3='python3 -m pip' | ||
| 533 | # }}} | 532 | # }}} |
| 534 | # GIS {{{ | 533 | # GIS {{{ |
| 535 | alias oo='ogr2ogr' | 534 | alias oo='ogr2ogr' |