mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
Merge be1837233b into de78e47d27
This commit is contained in:
commit
734f0a23f6
8 changed files with 464 additions and 80 deletions
|
|
@ -2,80 +2,33 @@ alias bi="bower install"
|
||||||
alias bl="bower list"
|
alias bl="bower list"
|
||||||
alias bs="bower search"
|
alias bs="bower search"
|
||||||
|
|
||||||
_bower_installed_packages () {
|
bower_package_list=''
|
||||||
bower_package_list=$(bower ls --no-color 2>/dev/null| awk 'NR>3{print p}{p=$0}'| cut -d ' ' -f 2|sed 's/#.*//')
|
|
||||||
}
|
|
||||||
_bower ()
|
_bower ()
|
||||||
{
|
{
|
||||||
local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production
|
local curcontext="$curcontext" state line
|
||||||
local expl
|
typeset -A opt_args
|
||||||
typeset -A opt_args
|
|
||||||
|
|
||||||
_no_color=('--no-color[Do not print colors (available in all commands)]')
|
_arguments -C \
|
||||||
|
':command:->command' \
|
||||||
|
'*::options:->options'
|
||||||
|
|
||||||
_dopts=(
|
case $state in
|
||||||
'(--save)--save[Save installed packages into the project"s bower.json dependencies]'
|
(command)
|
||||||
'(--force)--force[Force fetching remote resources even if a local copy exists on disk]'
|
compadd "$@" $(bower help --no-color | egrep '^\s+[a-z\-]+(, [a-z\-]+|)\s{2,}' | sed -e 's/^\s*//' -e 's/,//' | cut -d ' ' -f 1)
|
||||||
)
|
;;
|
||||||
|
|
||||||
_save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')
|
|
||||||
|
|
||||||
_force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]')
|
|
||||||
|
|
||||||
_production=('(--production)--production[Do not install project devDependencies]')
|
|
||||||
|
|
||||||
_1st_arguments=(
|
|
||||||
'cache-clean:Clean the Bower cache, or the specified package caches' \
|
|
||||||
'help:Display help information about Bower' \
|
|
||||||
'info:Version info and description of a particular package' \
|
|
||||||
'init:Interactively create a bower.json file' \
|
|
||||||
'install:Install a package locally' \
|
|
||||||
'link:Symlink a package folder' \
|
|
||||||
'lookup:Look up a package URL by name' \
|
|
||||||
'register:Register a package' \
|
|
||||||
'search:Search for a package by name' \
|
|
||||||
'uninstall:Remove a package' \
|
|
||||||
'update:Update a package' \
|
|
||||||
{ls,list}:'[List all installed packages]'
|
|
||||||
)
|
|
||||||
_arguments \
|
|
||||||
$_no_color \
|
|
||||||
'*:: :->subcmds' && return 0
|
|
||||||
|
|
||||||
if (( CURRENT == 1 )); then
|
|
||||||
_describe -t commands "bower subcommand" _1st_arguments
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$words[1]" in
|
|
||||||
install)
|
|
||||||
_arguments \
|
|
||||||
$_dopts \
|
|
||||||
$_save_dev \
|
|
||||||
$_force_lastest \
|
|
||||||
$_no_color \
|
|
||||||
$_production
|
|
||||||
;;
|
|
||||||
update)
|
|
||||||
_arguments \
|
|
||||||
$_dopts \
|
|
||||||
$_no_color \
|
|
||||||
$_force_lastest
|
|
||||||
_bower_installed_packages
|
|
||||||
compadd "$@" $(echo $bower_package_list)
|
|
||||||
;;
|
|
||||||
uninstall)
|
|
||||||
_arguments \
|
|
||||||
$_no_color \
|
|
||||||
$_dopts
|
|
||||||
_bower_installed_packages
|
|
||||||
compadd "$@" $(echo $bower_package_list)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
$_no_color \
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
(options)
|
||||||
|
case $line[1] in
|
||||||
|
(install)
|
||||||
|
if [ -z "$bower_package_list" ];then
|
||||||
|
bower_package_list=$(bower search --no-color | sed -e 's/^\s*//' | cut -d ' ' -f 1)
|
||||||
|
fi
|
||||||
|
compadd "$@" $(echo $bower_package_list)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
compdef _bower bower
|
compdef _bower bower
|
||||||
|
|
|
||||||
46
plugins/lesscss/lesscss.plugin.zsh
Normal file
46
plugins/lesscss/lesscss.plugin.zsh
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
# basics taken from here:
|
||||||
|
# http://www.ravelrumba.com/blog/watch-compile-less-command-line/comment-page-1/#comment-2464
|
||||||
|
# Requires watchr: https://github.com/mynyml/watchr
|
||||||
|
|
||||||
|
watchless () {
|
||||||
|
compressed=0
|
||||||
|
compile=""
|
||||||
|
|
||||||
|
while getopts ":xc:h" option
|
||||||
|
do
|
||||||
|
case $option in
|
||||||
|
x ) compressed=1 ;;
|
||||||
|
c ) compile=$OPTARG ;;
|
||||||
|
h ) _watchless_usage; return ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $compressed -eq 1 ]; then
|
||||||
|
x=' -x'
|
||||||
|
else
|
||||||
|
x=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$compile" ]; then
|
||||||
|
if [ ! -e $compile ]; then
|
||||||
|
echo "\033[337;41m\n$compile doesn't exist!\n\033[0m"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
name=$(echo $compile | cut -d . -f 1)
|
||||||
|
|
||||||
|
watchr -e 'watch(".*\.less$") { |f| system("lessc '$name'.less > '$name'.css'$x' && echo \"'$name'.less > '$name'.css\" ") }'
|
||||||
|
else
|
||||||
|
watchr -e 'watch(".*\.less$") { |f| system("lessc #{f[0]} > $(echo #{f[0]} | cut -d\. -f1).css'$x' && echo \"#{f[0]} > $(echo #{f[0]} | cut -d\. -f1).css\" ") }'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_watchless_usage () {
|
||||||
|
echo "Usage: watchless [options]"
|
||||||
|
echo
|
||||||
|
echo "Options"
|
||||||
|
echo " -x Compiles less files into minified css files"
|
||||||
|
echo " -c Watch all files but compile only the one given here"
|
||||||
|
echo " -h Get this help message"
|
||||||
|
return
|
||||||
|
}
|
||||||
185
plugins/nginx/nginx.plugin.zsh
Normal file
185
plugins/nginx/nginx.plugin.zsh
Normal file
|
|
@ -0,0 +1,185 @@
|
||||||
|
: ${NGINX_DIR:=/etc/nginx}
|
||||||
|
: ${NGINX_VHOST_TEMPLATE:=$ZSH/plugins/nginx/templates/symfony2}
|
||||||
|
|
||||||
|
if [[ -e $( which -p sudo 2>&1 ) ]]; then
|
||||||
|
sudo="sudo"
|
||||||
|
else
|
||||||
|
sudo=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# nginx basic completition
|
||||||
|
|
||||||
|
_nginx_get_en_command_list () {
|
||||||
|
ls -a $NGINX_DIR/sites-available | awk '/^[a-z][a-z.-]+$/ { print $1 }'
|
||||||
|
}
|
||||||
|
|
||||||
|
_nginx_get_dis_command_list () {
|
||||||
|
ls -a $NGINX_DIR/sites-enabled | awk '/^[a-z][a-z.-]+$/ { print $1 }'
|
||||||
|
}
|
||||||
|
|
||||||
|
_nginx_en () {
|
||||||
|
compadd `_nginx_get_en_command_list`
|
||||||
|
}
|
||||||
|
|
||||||
|
_nginx_dis () {
|
||||||
|
compadd `_nginx_get_dis_command_list`
|
||||||
|
}
|
||||||
|
|
||||||
|
# Enabling a site
|
||||||
|
en () {
|
||||||
|
if [ ! $1 ]; then
|
||||||
|
echo "\033[337;41m\nThe name of the vhost is required!\n\033[0m";
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $NGINX_DIR/sites-available/$1 ]; then
|
||||||
|
echo "\033[31m$1\033[0m doesn't exist";
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $NGINX_DIR/sites-enabled/$1 ]; then
|
||||||
|
$sudo ln -s $NGINX_DIR/sites-available/$1 $NGINX_DIR/sites-enabled/$1;
|
||||||
|
if [ -e $NGINX_DIR/sites-enabled/$1 ]; then
|
||||||
|
echo "\033[32m$1\033[0m successfully enabled";
|
||||||
|
else
|
||||||
|
echo "An error occured during the enabling of \033[31m$1\033[0m";
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "\033[31m$1\033[0m is already enabled";
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _nginx_en en
|
||||||
|
|
||||||
|
# Disabling a site
|
||||||
|
dis () {
|
||||||
|
if [ ! $1 ]; then
|
||||||
|
echo "\033[337;41m\nThe name of the vhost is required!\n\033[0m";
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $NGINX_DIR/sites-enabled/$1 ]; then
|
||||||
|
echo "\033[31m$1\033[0m doesn't exist";
|
||||||
|
else
|
||||||
|
$sudo rm -f $NGINX_DIR/sites-enabled/$1;
|
||||||
|
if [ ! -e $NGINX_DIR/sites-enabled/$1 ]; then
|
||||||
|
echo "\033[32m$1\033[0m successfully disabled";
|
||||||
|
else
|
||||||
|
echo "An error occured during the disabling of \033[31m$1\033[0m";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _nginx_dis dis
|
||||||
|
|
||||||
|
# Completition of vhost
|
||||||
|
_nginx_get_possible_vhost_list () {
|
||||||
|
ls -a $HOME/www | awk '/^[^.][a-z0-9._]+$/ { print $1 }'
|
||||||
|
}
|
||||||
|
|
||||||
|
_nginx_vhost () {
|
||||||
|
compadd `_nginx_get_possible_vhost_list`
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parsing arguments
|
||||||
|
vhost () {
|
||||||
|
local user=$USER;
|
||||||
|
local template=$NGINX_VHOST_TEMPLATE
|
||||||
|
local tpl="non_existing_template"
|
||||||
|
local enable=1
|
||||||
|
local write_hosts=0
|
||||||
|
|
||||||
|
while getopts ":lu:t:nwh" option
|
||||||
|
do
|
||||||
|
case $option in
|
||||||
|
l ) ls $NGINX_DIR/sites-enabled; return ;;
|
||||||
|
u ) user=$OPTARG ;;
|
||||||
|
t ) tpl=$OPTARG ;;
|
||||||
|
n ) enable=0 ;;
|
||||||
|
w ) write_hosts=1 ;;
|
||||||
|
h ) _vhost_usage; return ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $[ $OPTIND - 1 ]
|
||||||
|
local vhost=$1
|
||||||
|
|
||||||
|
if [ -z "$vhost" ]; then
|
||||||
|
echo "\033[337;41m\nThe name of the vhost is required!\n\033[0m"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e $ZSH/plugins/nginx/templates/$tpl ]; then
|
||||||
|
local template=$ZSH/plugins/nginx/templates/$tpl
|
||||||
|
elif [ -e $tpl ]; then
|
||||||
|
local template=$tpl
|
||||||
|
fi
|
||||||
|
|
||||||
|
_vhost_generate $vhost $user
|
||||||
|
|
||||||
|
if [ $enable -eq 1 ]; then
|
||||||
|
en $vhost
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $write_hosts -eq 1 ]; then
|
||||||
|
_write_hosts $vhost
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
compdef _nginx_vhost vhost
|
||||||
|
|
||||||
|
_vhost_usage () {
|
||||||
|
echo "Usage: vhost [options] [vhost_name]"
|
||||||
|
echo
|
||||||
|
echo "Options"
|
||||||
|
echo " -l Lists enabled vhosts"
|
||||||
|
echo " -u Sets the user - defaults to the current user ($USER)"
|
||||||
|
echo " -t Sets the template"
|
||||||
|
echo " -n Does not enable the generated vhost"
|
||||||
|
echo " -w Write the vhost to the /etc/hosts file pointing to 127.0.0.1 (writes it at the end of the first line actually)"
|
||||||
|
echo " -h Get this help message"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generate config file
|
||||||
|
_vhost_generate () {
|
||||||
|
local user=$(cat /etc/passwd | grep $2 | awk -F : '{print $1 }')
|
||||||
|
|
||||||
|
if [ ! $user ]; then
|
||||||
|
echo "User \033[31m$2\033[0m doesn't have an account on \033[33m$HOST\033[0m"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Generating \033[32m$1\033[0m vhost for \033[33m$user\033[0m user"
|
||||||
|
|
||||||
|
local user_id=$(cat /etc/passwd | grep $2 | awk -F : '{print $3 }')
|
||||||
|
local pool_port=1$user_id
|
||||||
|
|
||||||
|
sed -e 's/{vhost}/'$1'/g' -e 's/{user}/'$user'/g' -e 's/{pool_port}/'$pool_port'/g' $template | tee > $1.tmp
|
||||||
|
|
||||||
|
$sudo mv $1.tmp $NGINX_DIR/sites-available/$1
|
||||||
|
|
||||||
|
if [ -e $NGINX_DIR/sites-available/$1 ]; then
|
||||||
|
echo "\033[32m$1\033[0m vhost has been successfully created"
|
||||||
|
else
|
||||||
|
echo "An error occured during the creating of \033[31m$1\033[0m vhost"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write the /etc/hosts file
|
||||||
|
_write_hosts () {
|
||||||
|
temp=$HOME/hosts.temp
|
||||||
|
exec < /etc/hosts
|
||||||
|
while read line
|
||||||
|
do
|
||||||
|
if [ -e $temp ]; then
|
||||||
|
echo "$line" >> $temp;
|
||||||
|
else
|
||||||
|
echo "$line $1" > $temp;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
$sudo mv $temp /etc/hosts;
|
||||||
|
|
||||||
|
echo "\033[32m$1\033[0m vhost has been successfully written in /etc/hosts"
|
||||||
|
}
|
||||||
|
|
||||||
|
alias ngt="$sudo nginx -t"
|
||||||
|
alias ngr="$sudo service nginx restart"
|
||||||
27
plugins/nginx/templates/plain_php
Normal file
27
plugins/nginx/templates/plain_php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
server {
|
||||||
|
root /home/{user}/www/{vhost};
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
server_name {vhost};
|
||||||
|
|
||||||
|
error_log /var/log/nginx/{vhost}.error.log;
|
||||||
|
access_log /var/log/nginx/{vhost}.access.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ $uri/index.php;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_pass unix:/var/run/php-fpm/{user}.socket;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||||
|
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param HTTPS off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
27
plugins/nginx/templates/symfony2
Normal file
27
plugins/nginx/templates/symfony2
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
server {
|
||||||
|
root /home/{user}/www/{vhost}/web;
|
||||||
|
index app_dev.php;
|
||||||
|
|
||||||
|
server_name {vhost};
|
||||||
|
client_max_body_size 10M;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/{vhost}.error.log;
|
||||||
|
access_log /var/log/nginx/{vhost}.access.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /app_dev.php$uri /app_dev.php$is_args$args;
|
||||||
|
}
|
||||||
|
|
||||||
|
# pass the PHP scripts to FastCGI server listening on unix sockets
|
||||||
|
location ~ ^/(app|app_dev|check)\.php(/|$) {
|
||||||
|
fastcgi_pass unix:/var/run/php-fpm/{user}.socket;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param HTTPS off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
75
plugins/php-fpm/php-fpm.plugin.zsh
Normal file
75
plugins/php-fpm/php-fpm.plugin.zsh
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
: ${FPM_DIR:=/etc/php5/fpm}
|
||||||
|
|
||||||
|
if [[ -e $( which -p sudo 2>&1 ) ]]; then
|
||||||
|
sudo="sudo"
|
||||||
|
else
|
||||||
|
sudo=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
_fpm_get_possible_pool_list () {
|
||||||
|
cat /etc/passwd | awk -F : '{print $1 }'
|
||||||
|
}
|
||||||
|
|
||||||
|
_fpm_pool () {
|
||||||
|
compadd `_fpm_get_possible_pool_list`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pool () {
|
||||||
|
while getopts ":lh" option
|
||||||
|
do
|
||||||
|
case $option in
|
||||||
|
l ) ls $FPM_DIR/pool.d; return ;;
|
||||||
|
h ) _pool_usage; return ;;
|
||||||
|
* ) _pool_usage; return ;; # Default.
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! $1 ]; then
|
||||||
|
user=$USER
|
||||||
|
else
|
||||||
|
user=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_pool_generate $user
|
||||||
|
}
|
||||||
|
compdef _fpm_pool pool
|
||||||
|
|
||||||
|
_pool_usage () {
|
||||||
|
echo "Usage: pool [options] [user]"
|
||||||
|
echo
|
||||||
|
echo "Options"
|
||||||
|
echo " -l Lists fpm pools"
|
||||||
|
echo " -h Get this help message"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_pool_generate () {
|
||||||
|
user=$(cat /etc/passwd | grep $1 | awk -F : '{print $1 }')
|
||||||
|
|
||||||
|
if [ ! $user ]; then
|
||||||
|
echo "User \033[31m$1\033[0m doesn't have an account on \033[33m$HOST\033[0m"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
group=$(groups $user | cut -d " " -f 3)
|
||||||
|
|
||||||
|
echo "Generating pool for \033[33m$user\033[0m user with \033[33m$group\033[0m group"
|
||||||
|
|
||||||
|
user_id=$(cat /etc/passwd | grep $1 | awk -F : '{print $3 }')
|
||||||
|
pool_port=1$user_id
|
||||||
|
: ${FPM_POOL_TEMPLATE:=$ZSH/plugins/php-fpm/templates/pool}
|
||||||
|
|
||||||
|
conf=$(sed -e 's/{user}/'$user'/g' -e 's/{group}/'$group'/g' -e 's/{pool_port}/'$pool_port'/g' $FPM_POOL_TEMPLATE )
|
||||||
|
|
||||||
|
echo $conf > $user.conf
|
||||||
|
$sudo mv $user.conf $FPM_DIR/pool.d/$user.conf
|
||||||
|
|
||||||
|
if [ -e $FPM_DIR/pool.d/$user.conf ]; then
|
||||||
|
echo "Pool for \033[32m$user\033[0m user has been successfully created"
|
||||||
|
else
|
||||||
|
echo "An error occured during the creating of pool for \033[31m$user\033[0m user"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
alias fpmr="$sudo service php5-fpm restart"
|
||||||
11
plugins/php-fpm/templates/pool
Normal file
11
plugins/php-fpm/templates/pool
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[{user}]
|
||||||
|
user = {user}
|
||||||
|
group = {group}
|
||||||
|
|
||||||
|
listen = /var/run/php-fpm/{user}.socket
|
||||||
|
|
||||||
|
pm = dynamic
|
||||||
|
pm.max_children = 10
|
||||||
|
pm.min_spare_servers = 1
|
||||||
|
pm.max_spare_servers = 3
|
||||||
|
pm.max_requests = 100
|
||||||
|
|
@ -1,21 +1,81 @@
|
||||||
# Symfony2 basic command completion
|
# Symfony2 basic command completion
|
||||||
|
# And one step further
|
||||||
|
|
||||||
|
: ${SYMFONY_COMPLETE_CONSOLE:=""}
|
||||||
|
: ${SYMFONY_COMPLETE_ENTITIES:=""}
|
||||||
|
|
||||||
|
_SYMFONY_COMPLETE_CONSOLE=(
|
||||||
|
./console
|
||||||
|
app/console
|
||||||
|
)
|
||||||
|
|
||||||
|
SYMFONY_DO_COMPLETE_CONSOLE=($_SYMFONY_COMPLETE_CONSOLE $SYMFONY_COMPLETE_CONSOLE)
|
||||||
|
|
||||||
|
_SYMFONY_COMPLETE_ENTITIES=(
|
||||||
|
doctrine:generate:crud
|
||||||
|
doctrine:generate:entities
|
||||||
|
doctrine:generate:form
|
||||||
|
generate:doctrine:crud
|
||||||
|
generate:doctrine:entities
|
||||||
|
generate:doctrine:form
|
||||||
|
)
|
||||||
|
|
||||||
|
SYMFONY_DO_COMPLETE_ENTITIES=($_SYMFONY_COMPLETE_ENTITIES $SYMFONY_COMPLETE_ENTITIES)
|
||||||
|
|
||||||
|
_symfony2 ()
|
||||||
|
{
|
||||||
|
local console=$words[1]
|
||||||
|
|
||||||
|
if [ ! -f "$console" ];then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local curcontext="$curcontext" state line
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
':command:->command' \
|
||||||
|
'*::options:->options'
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(command)
|
||||||
|
if [ -z "$symfony2_command_list" ];then
|
||||||
|
_symfony2_command_list=$(_symfony2_get_command_list $console)
|
||||||
|
fi
|
||||||
|
compadd "$@" $(echo $_symfony2_command_list)
|
||||||
|
;;
|
||||||
|
|
||||||
|
(options)
|
||||||
|
needle=$line[1]
|
||||||
|
if [[ ${SYMFONY_DO_COMPLETE_ENTITIES[(i)$needle]} -le ${#SYMFONY_DO_COMPLETE_ENTITIES} ]]; then
|
||||||
|
if [ -z "$symfony2_entity_list" ];then
|
||||||
|
_symfony2_entity_list=$(_symfony2_get_entity_list $console)
|
||||||
|
fi
|
||||||
|
compadd "$@" $(echo $_symfony2_entity_list)
|
||||||
|
else
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
_symfony2_get_command_list () {
|
_symfony2_get_command_list () {
|
||||||
php app/console --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
|
$1 --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' | sed -e 's/:/\:/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
_symfony2 () {
|
_symfony2_get_entity_list () {
|
||||||
if [ -f app/console ]; then
|
$1 doctrine:mapping:info | grep Bundle | cut -d ' ' -f 4 | awk '{ split($0, A, /\\/); for ( var in A ) { if ( match(A[var], /.*Bundle/) ) { bundle=A[var]; } } print bundle":"A[var] }'
|
||||||
compadd `_symfony2_get_command_list`
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compdef _symfony2 app/console
|
for console_command in $SYMFONY_DO_COMPLETE_CONSOLE
|
||||||
compdef _symfony2 sf
|
do
|
||||||
|
compdef _symfony2 $console_command
|
||||||
|
done
|
||||||
|
|
||||||
#Alias
|
#Alias
|
||||||
|
|
||||||
|
alias sf2='php app/console'
|
||||||
|
alias sf2clear='php app/console cache:clear'
|
||||||
alias sf='php app/console'
|
alias sf='php app/console'
|
||||||
alias sfcl='php app/console cache:clear'
|
alias sfcl='php app/console cache:clear'
|
||||||
alias sfroute='php app/console router:debug'
|
alias sfroute='php app/console router:debug'
|
||||||
alias sfgb='php app/console generate:bundle'
|
alias sfgb='php app/console generate:bundle'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue