From 13a4cac98088dacea5eadf2216941be7f568b7c6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 16 Nov 2021 07:49:01 -0500 Subject: [PATCH] use fish for repos downloading --- bin/{repos => gh-repos} | 13 ++++++++- fish.configlink/functions/repos.fish | 42 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) rename bin/{repos => gh-repos} (64%) create mode 100755 fish.configlink/functions/repos.fish diff --git a/bin/repos b/bin/gh-repos similarity index 64% rename from bin/repos rename to bin/gh-repos index 410fa40..f505d34 100755 --- a/bin/repos +++ b/bin/gh-repos @@ -20,7 +20,18 @@ selected=$(gh repo list "$organization" \ --header-lines=1 \ --layout=reverse \ --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-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}" +} diff --git a/fish.configlink/functions/repos.fish b/fish.configlink/functions/repos.fish new file mode 100755 index 0000000..f1d9b3e --- /dev/null +++ b/fish.configlink/functions/repos.fish @@ -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