fisher/functions/__fisher_gist_to_name.fish
2016-02-20 09:57:51 +09:00

24 lines
450 B
Fish

function __fisher_gist_to_name -a url
set -l id (printf "%s\n" "$url" | sed 's|.*/||')
debug "Get Gist information '%s'" $url
set -l name (
spin "curl -Ss https://api.github.com/gists/$id" | awk '
/"files": / { files++ }
/"[^ ]+.fish": / && files {
gsub("^ *\"|\.fish.*", "")
print
}
'
)
if test -z "$name"
return 1
end
printf "%s\n" $name
end