Last active
July 26, 2022 21:40
-
-
Save shufo/513c453674d3885d0afbfb6bf3413882 to your computer and use it in GitHub Desktop.
gh cli alias importer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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