Browse Source

+ artisan bash autocompletion

* turn off mc client from workspace base image
master
dimti 3 weeks ago
parent
commit
5dcd3a131c
  1. 4
      src/.env
  2. 84
      src/dockerfiles/workspace/completion.sh
  3. 8
      src/dockerfiles/workspace/workspace.base.Dockerfile

4
src/.env

@ -6,12 +6,12 @@ WORKSPACE_INSTALL_SSH=true
WORKSPACE_INSTALL_MYSQL_CLIENT=true
WORKSPACE_INSTALL_FSWATCH=false
WORKSPACE_INSTALL_PING=true
WORKSPACE_INSTALL_S3_MINIO_CLIENT=true
WORKSPACE_INSTALL_S3_MINIO_CLIENT=false
WORKSPACE_INSTALL_BZ2=true
# PHP-extensions already installed: INTL, PGSQL, BCMATH
WORKSPACE_INSTALL_WP_CLI=true
WORKSPACE_INSTALL_NODE=true
WORKSPACE_INSTALL_GULP=true
WORKSPACE_INSTALL_GULP=false
WORKSPACE_INSTALL_YARN=true
WORKSPACE_NODE_VERSION=lts/hydrogen
WORKSPACE_NPM_REGISTRY=

84
src/dockerfiles/workspace/completion.sh

@ -0,0 +1,84 @@
# This file is part of the Symfony package.
#
# (c) Fabien Potencier <fabien@symfony.com>
#
# For the full copyright and license information, please view
# https://symfony.com/doc/current/contributing/code/license.html
_sf_artisan() {
# Use newline as only separator to allow space in completion values
IFS=$'\n'
local sf_cmd="${COMP_WORDS[0]}"
# for an alias, get the real script behind it
sf_cmd_type=$(type -t $sf_cmd)
if [[ $sf_cmd_type == "alias" ]]; then
sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
elif [[ $sf_cmd_type == "file" ]]; then
sf_cmd=$(type -p $sf_cmd)
fi
if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
return 1
fi
local cur prev words cword
_get_comp_words_by_ref -n := cur prev words cword
local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-a1")
for w in ${words[@]}; do
w=$(printf -- '%b' "$w")
# remove quotes from typed values
quote="${w:0:1}"
if [ "$quote" == \' ]; then
w="${w%\'}"
w="${w#\'}"
elif [ "$quote" == \" ]; then
w="${w%\"}"
w="${w#\"}"
fi
# empty values are ignored
if [ ! -z "$w" ]; then
completecmd+=("-i$w")
fi
done
local sfcomplete
if sfcomplete=$(${completecmd[@]} 2>&1); then
local quote suggestions
quote=${cur:0:1}
# Use single quotes by default if suggestions contains backslash (FQCN)
if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then
quote=\'
fi
if [ "$quote" == \' ]; then
# single quotes: no additional escaping (does not accept ' in values)
suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done)
elif [ "$quote" == \" ]; then
# double quotes: double escaping for \ $ ` "
suggestions=$(for s in $sfcomplete; do
s=${s//\\/\\\\}
s=${s//\$/\\\$}
s=${s//\`/\\\`}
s=${s//\"/\\\"}
printf $'%q%q%q\n' "$quote" "$s" "$quote";
done)
else
# no quotes: double escaping
suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done)
fi
COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur")))
__ltrim_colon_completions "$cur"
else
if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then
>&2 echo
>&2 echo $sfcomplete
fi
return 1
fi
}
complete -F _sf_artisan artisan

8
src/dockerfiles/workspace/workspace.base.Dockerfile

@ -252,6 +252,14 @@ USER root
RUN sed -i 's/^mozilla\/DST_Root_CA_X3\.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf && update-ca-certificates
###########################################################################
# Artisan bash autocompletion from symphony
# @see https://wintercms.com/docs/v1.2/docs/console/introduction#autocompletion--suggested-input-values
###########################################################################
RUN apt install bash-completion
COPY /completion.sh /etc/bash_completion.d/artisan
###########################################################################
# Tune opts:
###########################################################################

Loading…
Cancel
Save