added shell completion instructions

This commit is contained in:
Mike Farah 2020-06-11 18:50:38 +10:00
parent 6777d639c0
commit b0fa0e5b86

View File

@ -13,14 +13,29 @@ func createBashCompletionCmd(rootCmd *cobra.Command) *cobra.Command {
var completionCmd = &cobra.Command{ var completionCmd = &cobra.Command{
Use: "shell-completion", Use: "shell-completion",
Short: "Generates shell completion scripts", Short: "Generates shell completion scripts",
Long: `Example usage (for bash): to load completion run Long: `To load completion for:
bash:
Run
. <(yq bash-completion) . <(yq bash-completion)
To configure your bash shell to load completions for each session add to your bashrc To configure your bash shell to load completions for each session add to
your bashrc
# ~/.bashrc or ~/.profile # ~/.bashrc or ~/.profile
. <(yq bash-completion) . <(yq bash-completion)
zsh:
The generated completion script should be put somewhere in your $fpath named _yq
powershell:
Users need PowerShell version 5.0 or above, which comes with Windows 10 and
can be downloaded separately for Windows 7 or 8.1. They can then write the
completions to a file and source this file from their PowerShell profile,
which is referenced by the $Profile environment variable.
fish:
Save the output to a fish file and add it to your completions directory.
`, `,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
switch shellVariant { switch shellVariant {