Work with multiple GitHub accounts using the gh cli.
gh extension install gabe565/gh-profile
See the generated usage docs, or see a summary of each subcommand below.
Creates a new profile.
NAME
is optional. If not set, command will run interactively.
Activates a profile.
NAME
is optional. If not set, command will run interactively.- If set to
-
, gh-profile will switch back to the previous profile.
- If set to
--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.
Renames a profile.
NAME
andNEW_NAME
are optional. If not set, command will run interactively.
Lists all profiles. Active profile will be bold with a green check.
Removes a profile.
NAME
is optional. If not set, command will run interactively.
Prints the active profile name. If no profile is active, nothing will be printed. Useful as a 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 ships with a custom formatter for git
repositories. This
formatter can be easily modified to show the current profile.
- Edit
~/.p10k.zsh
. - Find the
my_git_formatter
function - Find the line
local res
- 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!
Before | After |
---|---|