diff options
author | eoli3n | 2020-11-16 10:20:30 +0100 |
---|---|---|
committer | eoli3n | 2020-11-16 10:20:30 +0100 |
commit | a1550aaa686a8d3315c385dccce8b4b0d3c232e6 (patch) | |
tree | 41233b03bbbfc5e70d481d85587bc7c1bd07fd61 | |
parent | a8399e64ad18046733573a9d8f60959ab3245956 (diff) | |
download | aur-a1550aaa686a8d3315c385dccce8b4b0d3c232e6.tar.gz |
bash to sh, added -t option, removed ix.io support
-rw-r--r-- | .SRCINFO | 8 | ||||
-rw-r--r-- | PKGBUILD | 8 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rwxr-xr-x | up | 97 |
4 files changed, 61 insertions, 62 deletions
@@ -1,13 +1,15 @@ pkgbase = upaste - pkgdesc = Paste and upload files on ix.io and x0.at - pkgver = 0.1.0 + pkgdesc = Paste and upload files on x0.at + pkgver = 0.1.1 pkgrel = 1 url = https://github.com/eoli3n/upaste arch = any license = UNLICENSE + optdepends = wl-clipboard: Command-line copy/paste utilities for Wayland + optdepends = xclip: Command line interface to the X11 clipboard source = up source = UNLICENSE - sha256sums = 65bb9054a584a0006a052cd1bfb8fe1617b3536df4ba8d812ec3b43e247f21d4 + sha256sums = 2d29aa3d2d9a4e36c4a0205fa3c5c630b26bfbb11c0708452ab8cd766b33d257 sha256sums = 6b0382b16279f26ff69014300541967a356a666eb0b91b422f6862f6b7dad17e pkgname = upaste @@ -1,14 +1,16 @@ # Maintainer: Jonathan Kirszling <jkirsz@gmail.com> pkgname=upaste pkgrel=1 -pkgver=0.1.0 -pkgdesc="Paste and upload files on ix.io and x0.at" +pkgver=0.1.1 +pkgdesc="Paste and upload files on x0.at" arch=('any') url="https://github.com/eoli3n/$pkgname" license=('UNLICENSE') +optdepends=('wl-clipboard: Command-line copy/paste utilities for Wayland' + 'xclip: Command line interface to the X11 clipboard') source=("up" "UNLICENSE") -sha256sums=("65bb9054a584a0006a052cd1bfb8fe1617b3536df4ba8d812ec3b43e247f21d4" +sha256sums=("2d29aa3d2d9a4e36c4a0205fa3c5c630b26bfbb11c0708452ab8cd766b33d257" "6b0382b16279f26ff69014300541967a356a666eb0b91b422f6862f6b7dad17e") package() { diff --git a/README.md b/README.md index 3883b1507663..e8d3e0e11882 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,7 @@ # upaste -Paste and upload files on ix.io and x0.at . -ix.io is used for piped text. -x0.at is used for stdin upload and file upload because it correctly set filetype. +x0.at paste client. ### Usage - -Bash file uploader - -Usage : - # Upload a file ``` $ up [OPTIONS] file @@ -27,3 +20,4 @@ C-d C-d Options : -h Print this usage -a Disable autocopy in clipboard + -t Set extension, without dot @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # x0.at paste client @@ -8,7 +8,7 @@ AUTOCOPY=1 # Functions -function usage(){ +usage () { filename=$(basename "$0") cat <<- EOF x0.at paste client @@ -34,74 +34,58 @@ Options : EOF } -function upload(){ +upload () { # Set vars local args - local url + local extension + local file + + # Set extension + if [ -n "$EXTENSION" ] + then + extension="filename=.$EXTENSION" + fi if [ -z "$1" ] then # If argument is empty, upload stdin local file="file=@-" + + # If extension not set, set .txt + if [ -z "$extension" ] + then + extension="filename=.txt" + fi + else # Else upload filename local file="file=@\"$1\"" fi - if [ -z "$EXTENSION" ] - then - local extension="filename=$EXTENSION" - fi - args="$file;$extension" - url=$(curl -s -F "$args" 'https://x0.at/') - return "$url" + # Curl call + curl -s -F "$args" 'https://x0.at/' } -# Arguments - -function arguments(){ - while getopts "hat:" arg "${args[@]}" - do - case $arg in - a) - AUTOCOPY=0 - ;; - h) - usage - exit - ;; - t) - EXTENSION=${OPTARG} - ;; - *) - usage - exit 1 - ;; - esac - done - shift $((OPTIND-1)) -} - -function autocopy(){ +autocopy () { # If xorg or wayland is running - if grep 'DISPLAY' <(env) &> /dev/null + if env | grep 'DISPLAY' >/dev/null 2>&1 then # If xclip is installed - if which xclip &> /dev/null + if which xclip >/dev/null 2>&1 then xclip "$1" # Else if wl-clipboard is installed - elif which wl-copy &> /dev/null + elif which wl-copy >/dev/null 2>&1 then wl-copy -p "$1" fi fi } -function is_file(){ +is_file () { # Test if first argument is an existing file if [ ! -f "$1" ] then @@ -110,14 +94,11 @@ function is_file(){ fi } -function main(){ +main () { # Vars local url - # Getopts - arguments "$@" - # If no piped data if [ -t 0 ] then @@ -126,7 +107,7 @@ function main(){ if [ -z "$1" ] then url=$(upload) - # Force a newline at the end + # Force a newline echo -e "\n" # Else upload argument and save url else @@ -162,5 +143,25 @@ function main(){ # Main -args=( "$@" ) -main "${args[@]}" +while getopts "hat:" arg +do + case $arg in + a) + AUTOCOPY=0 + ;; + h) + usage + exit + ;; + t) + EXTENSION=${OPTARG} + ;; + *) + usage + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +main "$@" |