Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- my ($first, @cmd);
- while ( <> ) {
- if ( /^([a-zA-Z0-9\-]+)/ ) {
- $first = $1;
- } elsif ( /^\s*(:[a-zA-Z0-9\-]+)/ ) {
- push @cmd, "$first$1";
- }
- }
- while ( <DATA> ) {
- my $cmd = join(' ', @cmd);
- $_ =~ s/__CMD/$cmd/;
- print $_;
- }
- #print `./symfony | perl -ne 'if( /^([a-zA-Z0-9\-]+)/ ) { $first = $1; } elsif ( /^\s*(:[a-zA-Z0-9\-]+)/ ) { print $first . $1 . "\n"; }'`
- __DATA__
- # Bash symfony completion
- #
- _symfony()
- {
- local cmds cur colonprefixes
- # cmds="$( ${COMP_WORDS[0]} | perl -ne 'if( /^([a-zA-Z0-9\-]+)/ ) { $first = $1; } elsif ( /^\s*(:[a-zA-Z0-9\-]+)/ ) { print $first . $1 . "\n"; }' )"
- cmds="__CMD__"
- COMPREPLY=()
- cur=${COMP_WORDS[COMP_CWORD]}
- # Work-around bash_completion issue where bash interprets a colon as a separator.
- # Work-around borrowed from the darcs work-around for the same issue.
- colonprefixes=${cur%"${cur##*:}"}
- COMPREPLY=( $(compgen -W '$cmds' -- $cur))
- local i=${#COMPREPLY[*]}
- while [ $((--i)) -ge 0 ]; do
- COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
- done
- return 0
- } &&
- complete -F _symfony symfony
Add Comment
Please, Sign In to add comment