-
-
Save niksingh710/7a93305fa0c039a0405addd5e9b33c7a to your computer and use it in GitHub Desktop.
This is ixio service script to but any text on ixio server and get a shareable link
This file contains hidden or 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
#!/usr/bin/env bash | |
# Examples: | |
# ix hello.txt # paste file (name/ext will be set). | |
# echo Hello world. | ix # read from STDIN (won't set name/ext). | |
# ix -n 1 self_destruct.txt # paste will be deleted after one read. | |
# ix -i ID hello.txt # replace ID, if you have permission. | |
# ix -d ID | |
ix() { | |
local opts | |
local OPTIND | |
[ -f "$HOME/.netrc" ] && opts='-n' | |
while getopts ":hd:i:n:" x; do | |
case $x in | |
h) | |
echo "ix [-d ID] [-i ID] [-n N] [opts]" | |
return | |
;; | |
d) | |
$echo curl $opts -X DELETE ix.io/$OPTARG | |
return | |
;; | |
i) | |
opts="$opts -X PUT" | |
local id="$OPTARG" | |
;; | |
n) opts="$opts -F read:1=$OPTARG" ;; | |
*) echo "Err" ;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
[ -t 0 ] && { | |
local filename="$1" | |
shift | |
[ "$filename" ] && { | |
curl $opts -F f:1=@"$filename" $* ix.io/$id | |
return | |
} | |
echo "^C to cancel, ^D to send." | |
} | |
RESULT=$(curl $opts -# -F f:1='<-' $* ix.io/$id) | |
hash wl-copy 2>/dev/null && echo $RESULT | wl-copy | |
echo $RESULT | |
} | |
ix $* | |
# e.g ~/.netrc | |
# machine ix.io | |
# login <username> | |
# password <pass> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment