LoginSignup
0
0

More than 1 year has passed since last update.

【Git】GitHub CLIをコマンド補完する方法

Posted at

Homebrewでインストールしている場合

GitHub CLIをHomebrewでインストールしている場合には以下のページの手順に沿って設定を行います。

zshの場合には以下を~/.zshrcに記述します。

~/.zshrc
if type brew &>/dev/null
then
  FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"

  autoload -Uz compinit
  compinit
fi

これでコマンドの補完ができるようになります。

gh を入力してタブを入力すると以下のように表示されます。

zsh
$ gh
alias       -- Create command shortcuts
api         -- Make an authenticated GitHub API request
auth        -- Authenticate gh and git with GitHub
browse      -- Open the repository in the browser
co          -- Alias for pr checkout
codespace   -- Connect to and manage codespaces
completion  -- Generate shell completion scripts
config      -- Manage configuration for gh
extension   -- Manage gh extensions
gist        -- Manage gists
gpg-key     -- Manage GPG keys
help        -- Help about any command
issue       -- Manage issues
label       -- Manage labels
pr          -- Manage pull requests
release     -- Manage releases
repo        -- Manage repositories
run         -- View details about workflow runs
search      -- Search for repositories, issues, and pull requests
secret      -- Manage GitHub secrets
ssh-key     -- Manage SSH keys
status      -- Print information about relevant issues, pull requests, and notifications across
workflow    -- View details about GitHub Actions workflows

Bashの場合

bashの場合にはbash-completionをイントールする必要があります。

bash-completionのインストール後に以下を~/.bash_profileまたは~/.bashrcに記述します。

~/.bashrc
eval "$(gh completion -s bash)"

gh を入力してタブを入力すると以下のように表示されます。

bash
$ gh 
alias       (Create command shortcuts)
api         (Make an authenticated GitHub API request)
auth        (Authenticate gh and git with GitHub)
browse      (Open the repository in the browser)
co          (Alias for pr checkout)
codespace   (Connect to and manage codespaces)
completion  (Generate shell completion scripts)
config      (Manage configuration for gh)
extension   (Manage gh extensions)
gist        (Manage gists)
gpg-key     (Manage GPG keys)
help        (Help about any command)
issue       (Manage issues)
label       (Manage labels)
pr          (Manage pull requests)
release     (Manage releases)
repo        (Manage repositories)
run         (View details about workflow runs)
search      (Search for repositories, issues, and pull requests)
secret      (Manage GitHub secrets)
ssh-key     (Manage SSH keys)
status      (Print information about relevant issues, pull requests, and notifications across repositories)
workflow    (View details about GitHub Actions workflows)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0