Skip to content

:octocat: Use multiple GitHub accounts with the gh cli.

License

Notifications You must be signed in to change notification settings

ulthuan/gh-profile

 
 

Repository files navigation

gh-profile

Build Go Report Card

Work with multiple GitHub accounts using the gh cli.

Installation

gh extension install gabe565/gh-profile

Usage

See the generated usage docs, or see a summary of each subcommand below.

gh profile create [NAME]

Creates a new profile.

Params

  • NAME is optional. If not set, command will run interactively.

gh profile switch [NAME] [--local-dir]

Activates a profile.

Params

  • NAME is optional. If not set, command will run interactively.
    • If set to -, gh-profile will switch back to the previous profile.
  • --local-dir/-l activates the profile only for the current directory.
    • For this to work, you must install a per-directory env tool like direnv.

gh profile rename [NAME] [NEW_NAME]

Renames a profile.

Params

  • NAME and NEW_NAME are optional. If not set, command will run interactively.

gh profile list

Lists all profiles. Active profile will be bold with a green check.

gh profile remove [NAME]

Removes a profile.

Params

  • NAME is optional. If not set, command will run interactively.

gh profile show

Prints the active profile name. If no profile is active, nothing will be printed. Useful as a prompt element.

Prompt Element

gh profile show is useful for displaying the current profile in your shell's prompt. This command will work for any prompt, but configuration with Powerlevel10k is provided below.

Powerlevel10k

Powerlevel10k ships with a custom formatter for git repositories. This formatter can be easily modified to show the current profile.

  1. Edit ~/.p10k.zsh.
  2. Find the my_git_formatter function
  3. Find the line local res
  4. Add the following below that line:
        local profile="$(gh profile show 2>/dev/null)"
        [[ -n "$profile" ]] && res+="$profile "

Now, the current profile will be shown when you are in a git repo!

Example

Before After
Before After

About

:octocat: Use multiple GitHub accounts with the gh cli.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%