Last active
December 27, 2017 03:11
-
-
Save ryotako/4e1c25802ba75286ed022c892c8ab36d to your computer and use it in GitHub Desktop.
funcgist.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defined in /Users/Ryota/.config/fish/functions/funcgist.fish @ line 1 | |
function funcgist | |
if not type -q gist | |
echo "funcgist: command 'gist' is required" >&2 | |
end | |
argparse -n funcgist 'h/help' 'd/description=' -- $argv | |
or return 1 | |
if set -q _flag_h | |
string trim " | |
NAME: | |
funcgist - Upload functions to Gist | |
USAGE: | |
funcgist [options] function... | |
OPTIONS: | |
-h, --help Show this help | |
" | |
return | |
end | |
for func in $argv | |
if not functions -q $func | |
echo "funcgist: Unknown function '$func'" >&2 | |
return 1 | |
end | |
end | |
set -l gists (gist -l) | |
for func in $argv | |
set -l file "$func.fish" | |
set -l gist (string match "* $file " $gists) | |
set -l url | |
if count $gist >/dev/null | |
echo $gist[1] | awk '{print $1}' | read url | |
functions $func | gist -f "$file" -d "$file" -u "$url" | read url | |
and echo "$url $file " | |
else | |
functions $func | gist -f "$file" -d "$file" | read url | |
and echo "$url $file " | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment