dotfiles

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

commit 0a8455707a194a554539593c1bfb488a5f9afb7f
parent 49ded058b1827817ffc7858676c2514a4baf677b
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Mon, 25 May 2020 21:19:42 +0200

upload: upload any file using nullptr

Former-commit-id: fc02d8b03138d82836d3167996c8d7389d153c90
Diffstat:
Ascripts/upload | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/scripts/upload b/scripts/upload @@ -0,0 +1,22 @@ +#!/bin/sh +if ! command -v curl 1>/dev/null 2>&1; then + echo "curl not installed." >&2 + exit 1 +fi +if ! command -v clipcopy 1>/dev/null 2>&1; then + echo "clipcopy script not present." >&2 + exit 1 +fi + +die() { + echo "$1" >&2 + exit 1 +} + +[ $# -eq 1 ] || die "File not provided as first argument." +[ -f "$1" ] || die "File $1 does not exist." +response=$(curl -s -F file=@"$1" http://0x0.st) +printf 'Response: %s' "$response" +{ printf '%s' "$response" | sed 's/^.*\(http[^"]*\).*/\1/' | clipcopy; } || echo "Direct link copied to clipboard." + +