Skip to content

Instantly share code, notes, and snippets.

@shufo
Last active July 26, 2022 21:40
Show Gist options
  • Save shufo/513c453674d3885d0afbfb6bf3413882 to your computer and use it in GitHub Desktop.
Save shufo/513c453674d3885d0afbfb6bf3413882 to your computer and use it in GitHub Desktop.
gh cli alias importer
Currently there is no command to import gh alias easily, so this is workaround
1. Export the gh alias
```bash
$ gh alias list > gh_aliases.txt
```
2. create import script
create `gh_alias_import.sh`
```bash
#!/bin/bash
TARGET=$1
echo "import gh aliases..."
while read line ; do
ALIAS=$(echo $line | cut -f 1 -d:)
COMMAND=$(echo $line | cut -f 2 -d: | sed -e 's/^\s*//')
echo "execute: gh alias set $ALIAS \'$COMMAND\'"
gh alias set $ALIAS "$COMMAND"
done < $1
echo "finish!"
```
3. Exec script
```
$ sh gh_alias_import.sh gh_aliases.txt
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment