Skip to content

Instantly share code, notes, and snippets.

@samtay
Last active August 13, 2018 16:40
Show Gist options
  • Save samtay/6086149b103e4bbe3ceededb6da0ed27 to your computer and use it in GitHub Desktop.
Save samtay/6086149b103e4bbe3ceededb6da0ed27 to your computer and use it in GitHub Desktop.
Auto completion & portability for bin/magento
# ------------------------------------------------------------------------------
# FILE: m2.plugin.zsh
# DESCRIPTION: oh-my-zsh m2 autocomplete file. Adapted from composer plugin
# AUTHOR: Sam Tay ([email protected])
# VERSION: 1.0.0
# ------------------------------------------------------------------------------
# Keep this up to date by checking bin-magento list --raw --no-ansi
_bin_magento_get_command_list () {
bin-magento --raw --no-ansi list | sed "s/[[:space:]].*//g"
}
_bin_magento () {
compadd $(_bin_magento_get_command_list)
}
compdef _bin_magento bin-magento
# Get magento webroot
function get-magento-root() {
local magentopath=`git rev-parse --show-toplevel`;
if [ -d "$magentopath/webroot" ]; then
magentopath="$magentopath/webroot"
fi
echo $magentopath;
}
# bin/magento from anywhere in git root
function bin-magento(){
php $(get-magento-root)/bin/magento -vvv "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment