Last active
July 15, 2026 18:00
-
-
Save peterjaffray/0f2bdc0b297a87d5aada90e62816e11d to your computer and use it in GitHub Desktop.
wp-cli completions for fish cli //~/.config/fish/completions/wp.fish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wp-cli completions for fish cli //~/.config/fish/completions/wp.fish | |
| function __wp_complete | |
| set -l old_ifs $IFS | |
| set -l cur (commandline -ct) | |
| set IFS \n | |
| set -l opts (wp cli completions --line=(commandline) --point=(commandline -C)) | |
| if string match -q --regex -- "\<file\>\s*" $opts | |
| return (commandline -f) | |
| else if test -z "$opts" | |
| return (commandline -f) | |
| else | |
| for opt in $opts | |
| printf '%s\n' $opt | |
| end | |
| end | |
| set IFS $old_ifs | |
| end | |
| complete -c wp -f -a "(__wp_complete)" |
Author
The bug is on line 10: string match chokes on $opts values like --role= because they look like option flags to string match itself. Let me fix it properly... one sec. Thank you for the comment!!@
Author
Good catch, thanks. The completion helper was passing wp-cli's ---prefixed option tokens (--role=, --url=, etc.) straight into string match, which parsed them as its own flags and aborted. Added a -- separator before the arguments (string match -q --regex -- "\<file\>\s*" $opts) and pushed the fix to the gist. Should complete cleanly now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fails to properly complete command options. Here's the output when I try to complete
wp @staging user list --(cursor is at end of that string, after--):