use fish for repos downloading

This commit is contained in:
Noah Masur 2021-11-16 07:49:01 -05:00
parent b9747c4e6f
commit 13a4cac980
2 changed files with 54 additions and 1 deletions

View File

@ -20,7 +20,18 @@ selected=$(gh repo list "$organization" \
--header-lines=1 \ --header-lines=1 \
--layout=reverse \ --layout=reverse \
--bind "ctrl-o:execute:gh repo view -w ${organization}/{1}" \ --bind "ctrl-o:execute:gh repo view -w ${organization}/{1}" \
--bind "shift-up:preview-half-page-up" \
--bind "shift-down:preview-half-page-down" \
--preview "GH_FORCE_TTY=49% gh repo view ${organization}/{1} | glow -" \ --preview "GH_FORCE_TTY=49% gh repo view ${organization}/{1} | glow -" \
--preview-window up --preview-window up
) )
[ -n "${selected}" ] && gh repo clone "${organization}/$(echo "${selected}" | awk '{print $1}')" [ -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}"
}

View File

@ -0,0 +1,42 @@
#!/usr/local/bin/fish
function repos --description 'Clone GitHub repositories' -a 'organization'
set directory (gh-repos $organization)
and cd $directory
end
#switch $organization
# case t2; set organization "take-two"
# case d2c; set organization "take-two-t2gp"
# case t2gp; set organization "take-two-t2gp"
# case pd; set organization "private-division"
# case dots; set organization "playdots"
# case '*'; set organization "nmasur"
#end
#set 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' \
# | begin
# echo "REPO,DESCRIPTION,UPDATED,LANGUAGE"
# cat -
# end | column -s , -t
# | fzf \
# --header-lines=1 \
# --layout=reverse
#--bind "ctrl-o:execute:gh repo view -w $organization/{1}" \
#--preview "GH_FORCE_TTY=49% gh repo view $organization/{1} | glow -" \
#--preview-window up
#)
#if test -n (echo $selected | tr -d '\r')
# set directory "$HOME/dev/work"
# if test $organization = "nmasur"
# set directory "$HOME/dev/personal"
# end
# set repo (echo $selected | awk '{print $1}')
# set repo_full "$organization/$repo"
# gh repo clone "$repo_full" "$directory/$repo"
# cd "$directory/$repo"
#end
#end