From fdc8dc5ec2f417c06f649c476d9e41ea9b1ee0b3 Mon Sep 17 00:00:00 2001 From: Aldis Ruiz <107271364+aldisruiz@users.noreply.github.com> Date: Thu, 30 May 2024 21:19:52 -0600 Subject: [PATCH 1/2] utils: add wp.fish Add Fish shell dynamic completions for wp-cli. --- utils/wp.fish | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 utils/wp.fish diff --git a/utils/wp.fish b/utils/wp.fish new file mode 100644 index 0000000000..001f84d788 --- /dev/null +++ b/utils/wp.fish @@ -0,0 +1,24 @@ +# Fish completion for the `wp` command +# Check $fish_complete_path for possible install locations +# Or check the documentation: +# https://fishshell.com/docs/current/completions.html#where-to-put-completions + +function __wp_cli_complete + # Get current buffer and cursor + set --local COMP_LINE (commandline) + set --local COMP_POINT (commandline -C) + + # Get valid completions from wp-cli + set --local opts (wp cli completions --line=$COMP_LINE --point=$COMP_POINT) + + # wp-cli will indicate if it needs a file + if string match -qe " " -- $opts + command ls -1 + else + # Remove unnecesary double spaces that wp-cli splits options with + string trim -- $opts + # `string` echoes each result on a newline. + # Which is then collected for use with the `-a` flag for `complete`. + end +end +complete -f -a "(__wp_cli_complete)" wp From 06564859821c52f6e53d2e1277928d68925b249e Mon Sep 17 00:00:00 2001 From: Aldis Ruiz <107271364+aldisruiz@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:14:36 -0600 Subject: [PATCH 2/2] utils: fix typo unnecesary -> unnecessary in wp.fish --- utils/wp.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/wp.fish b/utils/wp.fish index 001f84d788..a3671ba1c8 100644 --- a/utils/wp.fish +++ b/utils/wp.fish @@ -15,7 +15,7 @@ function __wp_cli_complete if string match -qe " " -- $opts command ls -1 else - # Remove unnecesary double spaces that wp-cli splits options with + # Remove unnecessary double spaces that wp-cli splits options with string trim -- $opts # `string` echoes each result on a newline. # Which is then collected for use with the `-a` flag for `complete`.