Kanji
・クラウドエンジニア / フリーランス ・1993年生まれ ・愛媛県出身 / 東京都渋谷区在住 ・AWS歴5年 プロフィールの詳細
gh auth login
目次
~/.config/gh/hosts.yml.${プロファイル名}
~/.config/gh/config.yml
git config --global 'credential.https://github.com.helper' '' git config --global --add 'credential.https://github.com.helper' '!gh auth git-credential'
aliases
create-profile
switch-profile
gh auth status
~/.config/gh/hosts.yml
git_protocol: https aliases: create-profile: '!gh auth status && read -p "Do you create this profile? (y/N): " yn; case "$yn" in [yY]*) cp ~/.config/gh/hosts.yml ~/.config/gh/hosts.yml.$1 && echo "[INFO] New hosts file created: ~/.config/gh/hosts.yml.$1";; esac' switch-profile: '!if [ -e ~/.config/gh/hosts.yml.$1 ]; then cp ~/.config/gh/hosts.yml.$1 ~/.config/gh/hosts.yml && gh auth status && echo "[INFO] Hosts file switched"; else echo "[ERROR] Hosts file not found: ~/.config/gh/hosts.yml.$1"; fi'
# プロファイル作成コマンド yq -o yaml -i '.aliases += {"create-profile": "''''!gh auth status && read -p \"Do you create this profile? (y/N): \" yn; case \"$yn\" in [yY]*) cp ~/.config/gh/hosts.yml ~/.config/gh/hosts.yml.$1 && echo \"[INFO] New hosts file created: ~/.config/gh/hosts.yml.$1\";; esac''''"}' ~/.config/gh/config.yml # プロファイル切り替えコマンド yq -o yaml -i '.aliases += {"switch-profile": "''''!if [ -e ~/.config/gh/hosts.yml.$1 ]; then cp ~/.config/gh/hosts.yml.$1 ~/.config/gh/hosts.yml && gh auth status && echo \"[INFO] Hosts file switched\"; else echo \"[ERROR] Hosts file not found: ~/.config/gh/hosts.yml.$1\"; fi''''"}' ~/.config/gh/config.yml
gh create-profile ${プロファイル名}
y
github.com ✓ Logged in to github.com as xxxxxxxxxx (oauth_token) ✓ Git operations for github.com configured to use https protocol. ✓ Token: ******************* Do you create this profile? (y/N): y [INFO] New hosts file created: ~/.config/gh/hosts.yml.xxxx
gh switch-profile ${プロファイル名}
# プロファイルが存在する場合 github.com ✓ Logged in to github.com as xxxxxxxxxx (oauth_token) ✓ Git operations for github.com configured to use https protocol. ✓ Token: *******************c [INFO] Hosts file switched # プロファイルが存在しない場合 [ERROR] Hosts file not found: ~/.config/gh/hosts.yml.test