aliases.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # ls
  3. alias l='ls -lFh' # size,show type,human readable
  4. alias la='ls -lAFh' # long list,show almost all,show type,human readable
  5. alias lr='ls -tRFh' # sorted by date,recursive,show type,human readable
  6. alias lt='ls -ltFh' # long list,sorted by date,show type,human readable
  7. alias ll='ls -l' # long list
  8. alias lth='lt | head -16' # latest 15
  9. alias dfh='df -h' # df
  10. # du
  11. alias duh="du -sh * | sort -h"
  12. # export local .env file
  13. alias export-env="export \$(grep -v '^#' .env | xargs -0)"
  14. # docker / podman
  15. if [ -f '/usr/bin/podman' ] || [ -f '/opt/homebrew/bin/podman' ]; then
  16. alias docker='podman'
  17. alias docker-compose='podman-compose'
  18. alias dc='docker-compose'
  19. else
  20. alias dc='docker compose'
  21. fi
  22. alias d='docker'
  23. # k8s
  24. alias k='kubectl'
  25. alias kx='kubectx'
  26. # http
  27. alias http-server='python3 -m http.server'
  28. # osx-only aliases
  29. if [[ "$(uname -s)" = 'Darwin' ]]; then
  30. alias get-buffer="$HOME/dotfiles/bin/get-iterm2-buffer"
  31. alias chrome-tabs="$HOME/dotfiles/bin/chrome-tabs"
  32. fi
  33. # node
  34. alias scripts="jq .scripts package.json"
  35. # other bin
  36. alias awsp="$HOME/dotfiles/bin/aws-profile"
  37. # display docker statuses
  38. alias dockerps="docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'"
  39. # set terminal title
  40. function title {
  41. echo -ne "\033]0;"$*"\007"
  42. }
  43. alias branchpr="git checkout -b fix/grrowl-\$(date +%s) && gh pr create -w"
  44. # generate password
  45. alias pwgen="openssl rand -base64"
  46. alias rssi="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | egrep -E 'agrCtlRSSI|agrCtlNoise|lastTxRate'"
  47. # dtach
  48. dtach-job() {
  49. if [ -z $2 ]; then
  50. dtach -a $1.dtach
  51. else
  52. dtach -n $1.dtach /bin/bash -c "${@:2} >> $1.log 2>&1"
  53. fi
  54. }
  55. # better watch
  56. alias watchx="watch -cd -n 2"
  57. # easy checkout
  58. checkout() {
  59. if [ -z "$*" ]; then
  60. echo "Needs arg"
  61. return
  62. fi
  63. DIR=$(echo "$@" | grep -Eo '[^/:]+/[^/]+\.git' | sed 's/\.git$//');
  64. git clone "$@" "$HOME/repos/$DIR" || return
  65. cd "$HOME/repos/$DIR" || return
  66. }
  67. # alias ac="aider --commit --model openrouter/meta-llama/llama-4-maverick:free"
  68. alias ac="git diff | llm -m openrouter/meta-llama/llama-4-maverick:free -s 'Write a concise, imperative-mood git commit message summarizing these changes.' | git commit -a -F -"
  69. alias pbjson="pbpaste | jq -r"
  70. alias pbjsons="pbpaste | jq -sRr '@json'"