aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxero <x@xero.nu>2015-01-07 22:30:37 -0500
committerxero <x@xero.nu>2015-01-07 22:30:37 -0500
commit358fd928982d8d529b0b13a9ef33fba5a0c7ed7e (patch)
treed1f2c51ba0c1b1f0999bcd6dbe4cb19644e61f4e
parente321d64e713864fd5dee22ed65c14efeaff20437 (diff)
downloaddotfiles_ascii-358fd928982d8d529b0b13a9ef33fba5a0c7ed7e.tar.xz
dotfiles_ascii-358fd928982d8d529b0b13a9ef33fba5a0c7ed7e.zip
add ix commandline pastebin
-rwxr-xr-xsys/code/sys/ix35
-rw-r--r--zsh/.zshrc1
2 files changed, 36 insertions, 0 deletions
diff --git a/sys/code/sys/ix b/sys/code/sys/ix
new file mode 100755
index 0000000..2cf7fa5
--- /dev/null
+++ b/sys/code/sys/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 $*
diff --git a/zsh/.zshrc b/zsh/.zshrc
index 6bba78b..7f7cf3e 100644
--- a/zsh/.zshrc
+++ b/zsh/.zshrc
@@ -50,6 +50,7 @@ alias img="bash ~/code/sys/img"
alias tmx="~/code/sys/tmx"
alias gitio"~/code/sys/gitio"
alias ascii="figlet -w `tput cols` -f 3d "
+alias ix="~/code/sys/ix"
dirlist() {
ls -la "$1" && echo -e '' && tree -a "$1"
}