dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 49ded058b1827817ffc7858676c2514a4baf677b
parent 62ae8ee8e1368fee0582007882c434862b248b16
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Mon, 25 May 2020 21:18:48 +0200

ix: cmdline pastebin

Former-commit-id: 7c8d401150115255e0bac5a7c3620f5092ca13e5
Diffstat:
Ascripts/ix | 36++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/scripts/ix b/scripts/ix @@ -0,0 +1,35 @@ +#!/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";; + 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." + } + curl $opts -F f:1='<-' $* ix.io/$id +} + +ix $*+ \ No newline at end of file