diff --git a/bin/ix b/bin/ix new file mode 100755 index 00000000..7fe70c93 --- /dev/null +++ b/bin/ix @@ -0,0 +1,50 @@ +#!/usr/bin/env zsh +# Sends file(s) or stdin to a ix.io +set -e + +_usage() { + more <&2 echo "$OPTARG requires an argument" + _usage + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +if (($# == 0)) && [[ -t 0 ]]; then + >&2 echo "Nothing in stdin and no files specified!" + >&2 _usage + exit 1 +fi + +url=$(cat "$@" | curl -s -F 'f:1=<-' ix.io) + +# Naive lang detection from file extension +[[ $1 == *.* && -z $lang ]] && lang="${1##*.}" +# Show url +url=$(printf "%s/%s" "$url" "$lang") +echo $url | clip +echo $url diff --git a/bin/sprunge b/bin/sprunge deleted file mode 100755 index 20854d51..00000000 --- a/bin/sprunge +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -# Sends file(s) or stdin to http://sprunge.us - -set -e - -usage() { - more <&2 echo "$OPTARG requires an argument" - usage - exit 1 - ;; - esac -done -shift $((OPTIND-1)) - -if (($# == 0)) && [[ -t 0 ]]; then - >&2 echo "Nothing in stdin and no files specified!" - >&2 usage - exit 1 -fi - -# Naive lang detection from file extension -[[ "$1" = *.* && -z "$lang" ]] && lang="?${1##*.}" - -# Read from stdin or read file(s) -url=$(sprunge $1) - -# Assemble URL+langstr and send to clipboard -printf "%s%s" "$url" "$lang" | pbcopy - -# Show URL to interactive users -[[ -t 0 ]] && pbpaste