CLI and APIs
Bring your gh aliases, and complete commands with Tab
You have gh aliases that you use every day, and you want Tab to complete the commands of src. src reads the alias format of gh, and makes a completion script for your shell.
2 min read
1. Copy your gh aliases
command gh alias list | src alias import -
src alias list
In PowerShell, run gh.exe alias list | src alias import -.
src keeps aliases and settings in the format of gh. The file is config.yml in ~/.config/src on macOS and Linux, and in %APPDATA%\src on Windows.
2. Make a new alias
src alias set bugs 'issue list --label bug'
src bugs
$1,$2and so on in an alias take the arguments after the alias name.--shellruns the alias throughsh, as gh does.srcrefuses an alias whose name is asrccommand, or whose commandsrcdoes not have.- To change an alias, add
--clobber.
3. Turn on Tab completion
Add one line to the startup file of your shell:
| Shell | Add this line | To |
|---|---|---|
| bash | eval "$(src completion -s bash)" | ~/.bashrc |
| zsh | source <(src completion -s zsh) | ~/.zshrc, after compinit |
| PowerShell | Invoke-Expression -Command $(src completion -s powershell | Out-String) | $PROFILE |
In fish, save the script once:
src completion -s fish > ~/.config/fish/completions/src.fish
Note
The script holds the commands of the src that made it. After you upgrade src, save the fish file again.
Done
In a new terminal, your gh aliases run in src, and Tab completes the commands and the flags of src.
Note
src config get, set and list read and write the settings of gh, with the keys of gh. src acts only on the aliases now.