my xfce4 dotfiles
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.

76 lines
2.3 KiB

3 years ago
  1. ## Basic Composer command completion
  2. # Since Zsh 5.7, an improved composer command completion is provided
  3. if ! is-at-least 5.7; then
  4. _composer () {
  5. local curcontext="$curcontext" state line
  6. typeset -A opt_args
  7. _arguments '*:: :->subcmds'
  8. if (( CURRENT == 1 )) || ( (( CURRENT == 2 )) && [[ "$words[1]" = "global" ]] ); then
  9. # Command list
  10. local -a subcmds
  11. subcmds=("${(@f)"$($_comp_command1 --no-ansi 2>/dev/null | awk '
  12. /Available commands/{ r=1 }
  13. r == 1 && /^[ \t]*[a-z]+/{
  14. gsub(/^[ \t]+/, "")
  15. gsub(/ +/, ":")
  16. print $0
  17. }
  18. ')"}")
  19. _describe -t commands 'composer command' subcmds
  20. else
  21. # Required list
  22. compadd $($_comp_command1 show -s --no-ansi 2>/dev/null \
  23. | sed '1,/requires/d' \
  24. | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }')
  25. fi
  26. }
  27. compdef _composer composer
  28. compdef _composer composer.phar
  29. fi
  30. ## Aliases
  31. alias c='composer'
  32. alias ccp='composer create-project'
  33. alias cdo='composer dump-autoload -o'
  34. alias cdu='composer dump-autoload'
  35. alias cget='curl -s https://getcomposer.org/installer | php'
  36. alias cgr='composer global require'
  37. alias cgrm='composer global remove'
  38. alias cgu='composer global update'
  39. alias ci='composer install'
  40. alias co='composer outdated'
  41. alias cod='composer outdated --direct'
  42. alias cr='composer require'
  43. alias crm='composer remove'
  44. alias cs='composer show'
  45. alias csu='composer self-update'
  46. alias cu='composer update'
  47. alias cuh='composer update --working-dir=$(composer config -g home)'
  48. ## If Composer not found, try to add known directories to $PATH
  49. if (( ! $+commands[composer] )); then
  50. [[ -d "$HOME/.composer/vendor/bin" ]] && export PATH="$PATH:$HOME/.composer/vendor/bin"
  51. [[ -d "$HOME/.config/composer/vendor/bin" ]] && export PATH="$PATH:$HOME/.config/composer/vendor/bin"
  52. # If still not found, don't do the rest of the script
  53. (( $+commands[composer] )) || return 0
  54. fi
  55. ## Add Composer's global binaries to PATH
  56. autoload -Uz _store_cache _retrieve_cache _cache_invalid
  57. _retrieve_cache composer
  58. if [[ -z $__composer_bin_dir ]]; then
  59. __composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null)
  60. _store_cache composer __composer_bin_dir
  61. fi
  62. # Add Composer's global binaries to PATH
  63. export PATH="$PATH:$__composer_bin_dir"
  64. unset __composer_bin_dir