Skip to content

Instantly share code, notes, and snippets.

@CarsonF
Created August 24, 2016 20:14
Show Gist options
  • Save CarsonF/2570352e05711a0bf1b9ba981909a79b to your computer and use it in GitHub Desktop.
Save CarsonF/2570352e05711a0bf1b9ba981909a79b to your computer and use it in GitHub Desktop.
Symfony Console Bash Completion
#!/usr/bin/env bash
function _symfony_complete {
local CMDLINE_CONTENTS="$COMP_LINE"
local CMDLINE_CURSOR_INDEX="$COMP_POINT"
local CMDLINE_WORDBREAKS="$COMP_WORDBREAKS";
export CMDLINE_CONTENTS CMDLINE_CURSOR_INDEX CMDLINE_WORDBREAKS
local RESULT STATUS;
RESULT="$($1 _completion </dev/null)";
STATUS=$?;
local cur mail_check_backup;
mail_check_backup=$MAILCHECK;
MAILCHECK=-1;
_get_comp_words_by_ref -n : cur;
if [ $STATUS -eq 200 ]; then
_filedir;
return 0;
elif [ $STATUS -ne 0 ]; then
echo -e "$RESULT";
return $?;
fi;
COMPREPLY=(`compgen -W "$RESULT" -- $cur`);
__ltrim_colon_completions "$cur";
MAILCHECK=mail_check_backup;
};
complete -F _symfony_complete "console" "nut";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment