fisher/functions/__fisher_gist_to_name.fish

22 lines
469 B
Fish
Raw Normal View History

2016-03-13 19:20:40 +00:00
function -S __fisher_gist_to_name -a url
set -l gist_id (printf "%s\n" "$url" | sed 's|.*/||')
set -l name (
2016-03-13 19:20:40 +00:00
spin "curl -Ss https://api.github.com/gists/$gist_id" -f " $color@$color_normal\r" | awk '
2016-03-13 19:20:40 +00:00
/"files": / { files++ }
2016-03-13 19:20:40 +00:00
/"[^ ]+.fish": / && files {
gsub("^ *\"|\.fish.*", "")
print
}
'
)
if test -z "$name"
return 1
end
printf "%s\n" $name
end