From 4c6b4188a07724eee3a94a73eca182df46f387c2 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Sat, 9 Feb 2019 22:22:58 -0800 Subject: [PATCH] Drastically improve `fish ` completions * complete .fish files * --debug -> --debug-level * add --init-command/-C * add --debug-stack-frames/-D * add --private/-P * add --features/-f: lists supported features, supports foo, * -c now completes commands * -d requires argument, describes 0..5 * --profile: require argument, allow file completion --- share/completions/fish.fish | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/share/completions/fish.fish b/share/completions/fish.fish index d33d20bc4..d11745b03 100644 --- a/share/completions/fish.fish +++ b/share/completions/fish.fish @@ -1,8 +1,24 @@ -complete -c fish -s c -l "command" -d "Run fish with this command" +complete -c fish -s c -l command -d "Run specified command instead of interactive session" -x -a "(__fish_complete_command)" +complete -c fish -s C -l init-command -d "Run specified command before session" -x -a "(__fish_complete_command)" complete -c fish -s h -l help -d "Display help and exit" complete -c fish -s v -l version -d "Display version and exit" complete -c fish -s n -l no-execute -d "Only parse input, do not execute" complete -c fish -s i -l interactive -d "Run in interactive mode" -complete -c fish -s l -l login -d "Run in login mode" -complete -c fish -s p -l profile -d "Output profiling information to specified file" -f -complete -c fish -s d -l debug -d "Run with the specified verbosity level" +complete -c fish -s l -l login -d "Run as a login shell" +complete -c fish -s p -l profile -d "Output profiling information to specified file" -r +complete -c fish -s d -l debug-level -d "Specify verbosity level" -x -a "0\t'Warnings silenced' +1\t'Default' +2\t'Basic debug output' +3\t'More debug output' +4\t'Much more debug output' +5\t'Too much debug output'" +complete -c fish -s D -l debug-stack-frames -d "Show specified # of frames with debug output" -x -a "(seq 128)\t\n" +complete -c fish -s P -l private -d "Do not persist history" + +function __fish_complete_features + set -l arg_comma (commandline -tc | string replace -rf '(.*,)[^,]*' '$1' | string replace -r -- '--.*=' '') + set -l features (status features | string replace -rf '^([\w-]+).*\t(.*)$' '$1\t$2') + printf "%s\n" "$arg_comma"$features #TODO: remove existing args +end +complete -c fish -s f -l features -d "Run with comma-separated feature flags enabled" -a "(__fish_complete_features)" -x +complete -c fish -x -a "(__fish_complete_suffix .fish)"