Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Duplicate methods of generating shell completion scripts #8862

Closed
marckhouzam opened this issue Aug 6, 2021 · 2 comments · Fixed by #9450
Closed

Duplicate methods of generating shell completion scripts #8862

marckhouzam opened this issue Aug 6, 2021 · 2 comments · Fixed by #9450

Comments

@marckhouzam
Copy link

This may not be considered a bug, but I wanted to make the maintainers aware of the situation.

$ hugo gen autocomplete -h |head -1
Generates a shell autocompletion script for Hugo.

$ hugo completion -h | head -2
Generate the autocompletion script for hugo for the specified shell.

To facilitate the use of shell completion, Cobra 1.2 automatically provides a "completion" command (https://github.com/spf13/cobra/releases/tag/v1.2.0). This command needs to be explicitly disabled for programs that don't want to use it (https://github.com/spf13/cobra/blob/master/shell_completions.md#adapting-the-default-completion-command).

Hugo 0.87.0 moved to Cobra 1.2.1 and has inherited this new "completion" command.

Note that the "completion" command provided by Cobra is more complete that the one defined in Hugo:

  • it provides completion descriptions for Powershell and Bash
  • it allows individual users to disable completion descriptions for all shells with the --no-descriptions flag
  • it uses bash completion V2 which has a 250-line script instead of the 3200-line one generated by Hugo

It is in part to avoid projects missing some of these subtle tweaks that Cobra provides the completion command itself.

What version of Hugo are you using (hugo version)?

0.87.0

Does this issue reproduce with the latest release?

Yes

@bep bep added the Bug label Aug 6, 2021
@bep bep added this to the v0.88 milestone Aug 6, 2021
@bep bep modified the milestones: v0.88, v0.89 Sep 2, 2021
@bep bep modified the milestones: v0.89, v0.90 Nov 2, 2021
@bep bep modified the milestones: v0.90, v0.91.0 Dec 8, 2021
@bep bep modified the milestones: v0.91.0, v0.92.0 Dec 20, 2021
@bep bep modified the milestones: v0.92.0, v0.93.0 Jan 12, 2022
jmooring added a commit to jmooring/hugo that referenced this issue Jan 31, 2022
@bep bep closed this as completed in #9450 Feb 1, 2022
bep pushed a commit that referenced this issue Feb 1, 2022
@austintraver
Copy link

Thank you for catching this @marckhouzam , I was using the other one by mistake prior to seeing this issue.

The zsh completions I'm getting now (generated via hugo completion) are incredibly comprehensive. For those reading this looking to do the same, redirect the output of hugo completion zsh to a file named _hugo, and locate it within one of the subdirectories set in the ${fpath} array. Your shell will load the completions the next time you start up a new session.

Supporting zsh documentation

@github-actions
Copy link

github-actions bot commented Feb 9, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants