From 425e4f2bdcac642f574746d75b9c298020a1315a Mon Sep 17 00:00:00 2001 From: Niklas Date: Sun, 7 Mar 2021 01:09:00 +0100 Subject: [PATCH] improved nc share --- .local/bin/nc-share | 1 + .local/bin/share-file | 1 - .local/share/scripts/nc-share-text.sh | 4 +--- .local/share/scripts/nc-share.sh | 25 +++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 120000 .local/bin/nc-share delete mode 120000 .local/bin/share-file create mode 100755 .local/share/scripts/nc-share.sh diff --git a/.local/bin/nc-share b/.local/bin/nc-share new file mode 120000 index 0000000..3ed6e74 --- /dev/null +++ b/.local/bin/nc-share @@ -0,0 +1 @@ +../share/scripts/nc-share.sh \ No newline at end of file diff --git a/.local/bin/share-file b/.local/bin/share-file deleted file mode 120000 index 2bf88f7..0000000 --- a/.local/bin/share-file +++ /dev/null @@ -1 +0,0 @@ -../share/scripts/nc-share-file.sh \ No newline at end of file diff --git a/.local/share/scripts/nc-share-text.sh b/.local/share/scripts/nc-share-text.sh index 7c61204..c35ad6e 100755 --- a/.local/share/scripts/nc-share-text.sh +++ b/.local/share/scripts/nc-share-text.sh @@ -20,7 +20,5 @@ FILENAME=$(basename $FILE_PATH) $SCRIPTPATH/nc-share-file.sh "$FILENAME" \ | perl -n -e '/([a-zA-Z0-9]+)$/ && print $1' \ - | awk -n -e '{print "https://pb.kapelle.org/"$1}' \ - | xclip -i -selection "clipboard" - + | awk -n -e '{print "https://pb.kapelle.org/"$1}' diff --git a/.local/share/scripts/nc-share.sh b/.local/share/scripts/nc-share.sh new file mode 100755 index 0000000..53258f7 --- /dev/null +++ b/.local/share/scripts/nc-share.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +set -e + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +if test -n "$1"; then + FILE_PATH=$1 +elif test ! -t 0; then + read -r FILE_PATH +else + >&2 echo "Provide a file" + exit 1 +fi + +FILENAME=$(basename $FILE_PATH) + + +if file -i -b "$FILENAME" | grep "text" &> /dev/null; then + $SCRIPTPATH/nc-share-text.sh "$FILENAME" +else + $SCRIPTPATH/nc-share-file.sh "$FILENAME" +fi +