dotfiles/bin/repos

27 lines
966 B
Plaintext
Raw Normal View History

2021-11-15 01:33:31 +00:00
#!/bin/sh
case $1 in
t2) organization="take-two" ;;
d2c) organization="take-two-t2gp" ;;
t2gp) organization="take-two-t2gp" ;;
pd) organization="private-division" ;;
dots) organization="playdots" ;;
*) organization="nmasur" ;;
esac
selected=$(gh repo list "$organization" \
--limit 50 \
--no-archived \
--json=name,description,isPrivate,updatedAt,primaryLanguage \
| jq -r '.[] | .name + "," + if .description == "" then "-" else .description end + "," + .updatedAt + "," + .primaryLanguage.name' \
| (echo "REPO,DESCRIPTION,UPDATED,LANGUAGE"; cat -) \
| column -s , -t \
| fzf \
--header-lines=1 \
--layout=reverse \
--bind "ctrl-o:execute:gh repo view -w ${organization}/{1}" \
2021-11-15 16:17:17 +00:00
--preview "GH_FORCE_TTY=49% gh repo view ${organization}/{1} | glow -" \
2021-11-15 01:33:31 +00:00
--preview-window up
)
[ -n "${selected}" ] && gh repo clone "${organization}/$(echo "${selected}" | awk '{print $1}')"