Skip to content
Source
Sign inSign up

Add aliases and Tab completion

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, $2 and so on in an alias take the arguments after the alias name.
  • --shell runs the alias through sh, as gh does.
  • src refuses an alias whose name is a src command, or whose command src does not have.
  • To change an alias, add --clobber.

3. Turn on Tab completion

Add one line to the startup file of your shell:

ShellAdd this lineTo
basheval "$(src completion -s bash)"~/.bashrc
zshsource <(src completion -s zsh)~/.zshrc, after compinit
PowerShellInvoke-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.