aliases.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #! /bin/bash
  2. # Colors used for status updates
  3. ESC_SEQ="\x1b["
  4. COL_RESET=$ESC_SEQ"39;49;00m"
  5. COL_RED=$ESC_SEQ"31;01m"
  6. COL_GREEN=$ESC_SEQ"32;01m"
  7. COL_YELLOW=$ESC_SEQ"33;01m"
  8. COL_BLUE=$ESC_SEQ"34;01m"
  9. COL_MAGENTA=$ESC_SEQ"35;01m"
  10. COL_CYAN=$ESC_SEQ"36;01m"
  11. # Detect which `ls` flavor is in use
  12. if ls --color > /dev/null 2>&1; then # GNU `ls`
  13. colorflag="--color"
  14. export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
  15. else # macOS `ls`
  16. colorflag="-G"
  17. export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
  18. fi
  19. # List all files colorized in long format
  20. #alias l="ls -lF ${colorflag}"
  21. ### MEGA: I want l and la ti return hisdden files
  22. alias l="ls -laF ${colorflag}"
  23. # List all files colorized in long format, including dot files
  24. alias la="ls -laF ${colorflag}"
  25. # List only directories
  26. alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
  27. # Always use color output for `ls`
  28. alias ls="command ls ${colorflag}"
  29. # Commonly Used Aliases
  30. alias ..="cd .."
  31. alias ...="cd ../.."
  32. alias ....="cd ../../.."
  33. alias .....="cd ../../../.."
  34. alias ~="cd ~" # `cd` is probably faster to type though
  35. alias -- -="cd -"
  36. alias home="cd ~"
  37. alias h="history"
  38. alias j="jobs"
  39. alias e='exit'
  40. alias c="clear"
  41. alias cla="clear && ls -la"
  42. alias cll="clear && ls -l"
  43. alias cls="clear && ls"
  44. alias code="cd /var/www"
  45. alias ea="vi ~/aliases.sh"
  46. # Always enable colored `grep` output
  47. # Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
  48. alias grep='grep --color=auto'
  49. alias fgrep='fgrep --color=auto'
  50. alias egrep='egrep --color=auto'
  51. alias art="php artisan"
  52. alias artisan="php artisan"
  53. alias cdump="composer dump-autoload -o"
  54. alias composer:dump="composer dump-autoload -o"
  55. alias db:reset="php artisan migrate:reset && php artisan migrate --seed"
  56. alias dusk="php artisan dusk"
  57. alias fresh="php artisan migrate:fresh"
  58. alias migrate="php artisan migrate"
  59. alias refresh="php artisan migrate:refresh"
  60. alias rollback="php artisan migrate:rollback"
  61. alias seed="php artisan db:seed"
  62. alias serve="php artisan serve --quiet &"
  63. alias pint="./vendor/bin/pint"
  64. alias pest="./vendor/bin/pest"
  65. alias phpstan="./vendor/bin/phpstan"
  66. alias php-cs-fixer="./vendor/bin/php-cs-fixer"
  67. alias phpunit="./vendor/bin/phpunit"
  68. alias pu="phpunit"
  69. alias puf="phpunit --filter"
  70. alias pud='phpunit --debug'
  71. alias cc='codecept'
  72. alias ccb='codecept build'
  73. alias ccr='codecept run'
  74. alias ccu='codecept run unit'
  75. alias ccf='codecept run functional'
  76. alias g="gulp"
  77. alias npm-global="npm list -g --depth 0"
  78. alias ra="reload"
  79. alias reload="source ~/.aliases && echo \"$COL_GREEN ==> Aliases Reloaded... $COL_RESET \n \""
  80. alias run="npm run"
  81. # Xvfb
  82. alias xvfb="Xvfb -ac :0 -screen 0 1024x768x16 &"
  83. # requires installation of 'https://www.npmjs.com/package/npms-cli'
  84. alias npms="npms search"
  85. # requires installation of 'https://www.npmjs.com/package/package-menu-cli'
  86. alias pm="package-menu"
  87. # requires installation of 'https://www.npmjs.com/package/pkg-version-cli'
  88. alias pv="package-version"
  89. # requires installation of 'https://github.com/sindresorhus/latest-version-cli'
  90. alias lv="latest-version"
  91. # git aliases
  92. alias gaa="git add ."
  93. alias gd="git --no-pager diff"
  94. alias git-revert="git reset --hard && git clean -df"
  95. alias gs="git status"
  96. alias whoops="git reset --hard && git clean -df"
  97. alias glog="git log --oneline --decorate --graph"
  98. alias gloga="git log --oneline --decorate --graph --all"
  99. alias gsh="git show"
  100. alias grb="git rebase -i"
  101. alias gbr="git branch"
  102. alias gc="git commit"
  103. alias gck="git checkout"
  104. # Create a new directory and enter it
  105. function mkd() {
  106. mkdir -p "$@" && cd "$@"
  107. }
  108. function md() {
  109. mkdir -p "$@" && cd "$@"
  110. }
  111. function xtree {
  112. find ${1:-.} -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
  113. }
  114. # `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
  115. # the `.git` directory, listing directories first. The output gets piped into
  116. # `less` with options to preserve color and line numbers, unless the output is
  117. # small enough for one screen.
  118. function tre() {
  119. tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
  120. }
  121. # Determine size of a file or total size of a directory
  122. function fs() {
  123. if du -b /dev/null > /dev/null 2>&1; then
  124. local arg=-sbh;
  125. else
  126. local arg=-sh;
  127. fi
  128. if [[ -n "$@" ]]; then
  129. du $arg -- "$@";
  130. else
  131. du $arg .[^.]* ./*;
  132. fi;
  133. }
  134. # Add artisan autocomplete
  135. function _artisan()
  136. {
  137. COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
  138. COMMANDS=`php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"`
  139. COMPREPLY=(`compgen -W "$COMMANDS" -- "${COMP_WORDS[COMP_CWORD]}"`)
  140. return 0
  141. }
  142. complete -F _artisan art
  143. complete -F _artisan artisan