You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.6 KiB

4 years ago
  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 phpunit="./vendor/bin/phpunit"
  64. alias pu="phpunit"
  65. alias puf="phpunit --filter"
  66. alias pud='phpunit --debug'
  67. alias cc='codecept'
  68. alias ccb='codecept build'
  69. alias ccr='codecept run'
  70. alias ccu='codecept run unit'
  71. alias ccf='codecept run functional'
  72. alias g="gulp"
  73. alias npm-global="npm list -g --depth 0"
  74. alias ra="reload"
  75. alias reload="source ~/.aliases && echo \"$COL_GREEN ==> Aliases Reloaded... $COL_RESET \n \""
  76. alias run="npm run"
  77. alias tree="xtree"
  78. # Xvfb
  79. alias xvfb="Xvfb -ac :0 -screen 0 1024x768x16 &"
  80. # requires installation of 'https://www.npmjs.com/package/npms-cli'
  81. alias npms="npms search"
  82. # requires installation of 'https://www.npmjs.com/package/package-menu-cli'
  83. alias pm="package-menu"
  84. # requires installation of 'https://www.npmjs.com/package/pkg-version-cli'
  85. alias pv="package-version"
  86. # requires installation of 'https://github.com/sindresorhus/latest-version-cli'
  87. alias lv="latest-version"
  88. # git aliases
  89. alias gaa="git add ."
  90. alias gd="git --no-pager diff"
  91. alias git-revert="git reset --hard && git clean -df"
  92. alias gs="git status"
  93. alias whoops="git reset --hard && git clean -df"
  94. alias glog="git log --oneline --decorate --graph"
  95. alias gloga="git log --oneline --decorate --graph --all"
  96. alias gsh="git show"
  97. alias grb="git rebase -i"
  98. alias gbr="git branch"
  99. alias gc="git commit"
  100. alias gck="git checkout"
  101. alias gull="git pull --rebase"
  102. alias gush="git push"
  103. # Create a new directory and enter it
  104. function mkd() {
  105. mkdir -p "$@" && cd "$@"
  106. }
  107. function md() {
  108. mkdir -p "$@" && cd "$@"
  109. }
  110. function xtree {
  111. find ${1:-.} -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
  112. }
  113. # `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
  114. # the `.git` directory, listing directories first. The output gets piped into
  115. # `less` with options to preserve color and line numbers, unless the output is
  116. # small enough for one screen.
  117. function tre() {
  118. tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
  119. }
  120. # Determine size of a file or total size of a directory
  121. function fs() {
  122. if du -b /dev/null > /dev/null 2>&1; then
  123. local arg=-sbh;
  124. else
  125. local arg=-sh;
  126. fi
  127. if [[ -n "$@" ]]; then
  128. du $arg -- "$@";
  129. else
  130. du $arg .[^.]* ./*;
  131. fi;
  132. }