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 \
|
2021-11-17 17:35:28 +00:00
|
|
|
| jq -r '.[] | .name + "," + if .description == "" then "-" else .description |= gsub(","; " ") | .description end + "," + .updatedAt + "," + .primaryLanguage.name' \
|
2021-11-15 01:33:31 +00:00
|
|
|
| (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-16 12:49:01 +00:00
|
|
|
--bind "shift-up:preview-half-page-up" \
|
|
|
|
--bind "shift-down:preview-half-page-down" \
|
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
|
|
|
|
)
|
2021-11-16 12:49:01 +00:00
|
|
|
[ -n "${selected}" ] && {
|
|
|
|
directory="$HOME/dev/work"
|
|
|
|
if [ $organization = "nmasur" ]; then directory="$HOME/dev/personal"; fi
|
|
|
|
repo=$(echo "${selected}" | awk '{print $1}')
|
|
|
|
repo_full="${organization}/${repo}"
|
|
|
|
if [ ! -d "${directory}/${repo}" ]; then
|
|
|
|
gh repo clone "$repo_full" "${directory}/${repo}"
|
|
|
|
fi
|
|
|
|
echo "${directory}/${repo}"
|
|
|
|
}
|