aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxero <x@xero.nu>2015-11-01 15:44:13 -0500
committerxero <x@xero.nu>2015-11-01 15:44:13 -0500
commita3d3bdcf454ed84b028038cf98ed40d3e3b29e1e (patch)
treed2553bf7feea9c683011da70f80ae9883332e328
parentd83a172950d90861d63b3891b14d5106e710502d (diff)
downloaddotfiles_ascii-a3d3bdcf454ed84b028038cf98ed40d3e3b29e1e.tar.xz
dotfiles_ascii-a3d3bdcf454ed84b028038cf98ed40d3e3b29e1e.zip
update gitio
Diffstat (limited to '')
-rwxr-xr-xbin/bin/gitio71
1 files changed, 39 insertions, 32 deletions
diff --git a/bin/bin/gitio b/bin/bin/gitio
index b6a7983..293ac4f 100755
--- a/bin/bin/gitio
+++ b/bin/bin/gitio
@@ -31,50 +31,57 @@ usage () {
-v shortlink
-h display this screen
EOF
- exit 0
+ exit 0
}
err() {
- echo $1
- usage
+ echo $1
+ usage
}
optstest() {
- found=0
- for arg in "$@"
- do
- if echo $arg | cut -d/ -f3 | grep -q "github.com\|raw.githubusercontent.com"
- then
- GHURL=$arg
- found=1
- elif [ $arg = "-h" ]
- then
- usage
- elif [ $arg = "-v" ]
- then
- :
- else
- VANITY=$arg
- fi
- done
- if [ $found = 0 ]
- then
- err " must be a valid github.com url!"
- fi
+ found=0
+ for arg in "$@"
+ do
+ if echo $arg | cut -d/ -f3 | grep -q "github.com\|raw.githubusercontent.com"
+ then
+ GHURL=$arg
+ found=1
+ elif [ $arg = "-h" ]
+ then
+ usage
+ elif [ $arg = "-v" ]
+ then
+ :
+ else
+ VANITY=$arg
+ fi
+ done
+ if [ $found = 0 ]
+ then
+ err " must be a valid github.com url!"
+ fi
}
case $# in
- 1)
- optstest $1 ;;
- 3)
- optstest $1 $2 $3 ;;
- *)
- err " invalid number of arguments!" ;;
+ 1)
+ optstest $1 ;;
+ 3)
+ optstest $1 $2 $3 ;;
+ *)
+ err " invalid number of arguments!" ;;
esac
if [ -z "$VANITY" ]
then
- curl -i http://git.io -F "url=$GHURL"
+ url=`curl -is http://git.io -F "url=$GHURL" | grep -i "location" | cut -d' ' -f2`
else
- curl -i http://git.io -F "url=$GHURL" -F "code=$VANITY"
+ url=`curl -is http://git.io -F "url=$GHURL" -F "code=$VANITY" | grep -i "location" | cut -d' ' -f2`
+fi
+
+if [ -z $url ]
+then
+ err " must be a valid github.com url!"
+else
+ echo $url
fi