Guest User

Untitled

a guest
Jul 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. my ($first, @cmd);
  7. while ( <> ) {
  8. if ( /^([a-zA-Z0-9\-]+)/ ) {
  9. $first = $1;
  10. } elsif ( /^\s*(:[a-zA-Z0-9\-]+)/ ) {
  11. push @cmd, "$first$1";
  12. }
  13. }
  14.  
  15. while ( <DATA> ) {
  16. my $cmd = join(' ', @cmd);
  17. $_ =~ s/__CMD/$cmd/;
  18. print $_;
  19. }
  20.  
  21. #print `./symfony | perl -ne 'if( /^([a-zA-Z0-9\-]+)/ ) { $first = $1; } elsif ( /^\s*(:[a-zA-Z0-9\-]+)/ ) { print $first . $1 . "\n"; }'`
  22.  
  23. __DATA__
  24. # Bash symfony completion
  25. #
  26. _symfony()
  27. {
  28. local cmds cur colonprefixes
  29.  
  30. # cmds="$( ${COMP_WORDS[0]} | perl -ne 'if( /^([a-zA-Z0-9\-]+)/ ) { $first = $1; } elsif ( /^\s*(:[a-zA-Z0-9\-]+)/ ) { print $first . $1 . "\n"; }' )"
  31. cmds="__CMD__"
  32. COMPREPLY=()
  33. cur=${COMP_WORDS[COMP_CWORD]}
  34. # Work-around bash_completion issue where bash interprets a colon as a separator.
  35. # Work-around borrowed from the darcs work-around for the same issue.
  36. colonprefixes=${cur%"${cur##*:}"}
  37. COMPREPLY=( $(compgen -W '$cmds' -- $cur))
  38. local i=${#COMPREPLY[*]}
  39. while [ $((--i)) -ge 0 ]; do
  40. COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
  41. done
  42.  
  43. return 0
  44. } &&
  45. complete -F _symfony symfony
Add Comment
Please, Sign In to add comment