Improve profile selection
This commit is contained in:
24
yc.fish
24
yc.fish
@@ -233,3 +233,27 @@ complete -c yc -n '__yc_clear_perform_completion_once_result'
|
|||||||
complete -c yc -n 'not __yc_requires_order_preservation && __yc_prepare_completions' -f -a '$__yc_comp_results'
|
complete -c yc -n 'not __yc_requires_order_preservation && __yc_prepare_completions' -f -a '$__yc_comp_results'
|
||||||
# otherwise we use the -k flag
|
# otherwise we use the -k flag
|
||||||
complete -k -c yc -n '__yc_requires_order_preservation && __yc_prepare_completions' -f -a '$__yc_comp_results'
|
complete -k -c yc -n '__yc_requires_order_preservation && __yc_prepare_completions' -f -a '$__yc_comp_results'
|
||||||
|
|
||||||
|
# custom part begins here
|
||||||
|
|
||||||
|
# Helper function to check previous commands
|
||||||
|
# Simplifies checking for subcommand sequences like 'config profile get'
|
||||||
|
function __fish_yc_using_command
|
||||||
|
set -l cmd (commandline -opc)
|
||||||
|
set -e cmd[1] # Remove the base command 'yc'
|
||||||
|
for i in (seq (count $argv))
|
||||||
|
if test "$cmd[$i]" != "$argv[$i]"
|
||||||
|
return 1 # Mismatch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0 # Match
|
||||||
|
end
|
||||||
|
|
||||||
|
function __fish_yc_list_profiles
|
||||||
|
yc config profile list | string replace ' ACTIVE' ''
|
||||||
|
end
|
||||||
|
|
||||||
|
complete -c yc -n '__fish_yc_using_command config profile get' -a '(__fish_yc_list_profiles)'
|
||||||
|
complete -c yc -n '__fish_yc_using_command config profile delete' -a '(__fish_yc_list_profiles)'
|
||||||
|
complete -c yc -n '__fish_yc_using_command config profile activate' -a '(__fish_yc_list_profiles)'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user