Linux command
gh-completion 命令
趣味
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Generate bash completions
gh completion -s bash > ~/.local/share/bash-completion/completions/gh
Generate zsh completions
gh completion -s zsh > "${fpath[1]}/_gh"
Generate fish completions
gh completion -s fish > ~/.config/fish/completions/gh.fish
Generate PowerShell completions
gh completion -s powershell | Out-String | Invoke-Expression
说明
gh completion generates shell completion scripts for the GitHub CLI. These scripts enable tab completion for gh commands, subcommands, flags, and dynamic values like repository names and branches. The completions integrate with each shell's native completion system, providing context-aware suggestions. Dynamic completions query GitHub for repositories, issues, and pull requests. Completion scripts should be regenerated after gh updates to include new commands.
参数
- -s _SHELL_, --shell _SHELL_
- Shell type: bash, zsh, fish, powershell.
- --help
- Display help information.
FAQ
What is the gh-completion command used for?
gh completion generates shell completion scripts for the GitHub CLI. These scripts enable tab completion for gh commands, subcommands, flags, and dynamic values like repository names and branches. The completions integrate with each shell's native completion system, providing context-aware suggestions. Dynamic completions query GitHub for repositories, issues, and pull requests. Completion scripts should be regenerated after gh updates to include new commands.
How do I run a basic gh-completion example?
Run `gh completion -s bash > ~/.local/share/bash-completion/completions/gh` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s _SHELL_, --shell _SHELL_ do in gh-completion?
Shell type: bash, zsh, fish, powershell.