Add 'fgh' script
This commit is contained in:
parent
7a0d019981
commit
c2bbdcbd3a
24
.local/bin/scripts/fgh
Executable file
24
.local/bin/scripts/fgh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Fuzzy cloner of GitHub repos.
|
||||
# Usage: fgh <user>
|
||||
|
||||
[ "$1" ] && user="$1" || user="$USER"
|
||||
|
||||
data() {
|
||||
curl -s -n "https://api.github.com/users/$user/repos?per_page=100&page=1"
|
||||
}
|
||||
|
||||
[ "$(data | grep "Not Found")" ] && { echo "[E] Incorrect user."; exit 1 ;}
|
||||
|
||||
repos() {
|
||||
data | jq --stream -r 'select(.[0][1] == "full_name") | .[1]'
|
||||
}
|
||||
|
||||
[ ! "$(repos)" ] && { echo "This user don't have any public repo!"; exit 0 ;}
|
||||
|
||||
chosen="$(repos | fzf --reverse --height=30%)"
|
||||
|
||||
[ ! "$chosen" ] && exit 0
|
||||
|
||||
git clone git@github.com:"$chosen"
|
Loading…
x
Reference in New Issue
Block a user