From 98507e35b721eb82b6da4d425e0d936b12353470 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 13 Oct 2023 11:35:53 +1100 Subject: [PATCH] feat: Add copy command --- README.md | 22 +++++++++++++++++++++- copy | 32 ++++++++++++++++++++++++++++++++ upload | 7 +++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 copy diff --git a/README.md b/README.md index 9f3db0a..17c5b50 100644 --- a/README.md +++ b/README.md @@ -16,5 +16,25 @@ upload ### Installation ```sh -sudo wget -O /usr/local/bin/upload https://git.woodburn.au/nathanwoodburn/scripts/raw/branch/main/upload && sudo chmod +x /usr/local/bin/upload +sudo apt install curl qrencode +sudo wget -O /usr/local/bin/upload https://git.woodburn.au/nathanwoodburn/scripts/raw/branch/main/upload +sudo chmod +x /usr/local/bin/upload +``` + +## Copy +This script is used for copying the contents of a file to the clipboard. + +### Usage +```sh +copy +``` + +### Dependencies +- xclip + +### Installation +```sh +sudo apt install xclip +sudo wget -O /usr/local/bin/copy https://git.woodburn.au/nathanwoodburn/scripts/raw/branch/main/copy +sudo chmod +x /usr/local/bin/copy ``` \ No newline at end of file diff --git a/copy b/copy new file mode 100644 index 0000000..334d285 --- /dev/null +++ b/copy @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copy file contents to clipboard +# Usage: copy +# ... | copy +# +# Author: Nathan Woodburn + +copy() { + if [ $# -eq 0 ]; then + echo "No arguments specified." + echo "Usage: copy " + return 1 + fi + + if tty -s; then + file="$1" + if [ ! -e "$file" ]; then + echo "$file: No such file or directory" >&2 + return 1 + fi + + xclip -selection clipboard < "$file" + + else + file_name="$1" + xclip -selection clipboard < "$file_name" + fi +} + +# Call the copy function with the provided arguments +copy "$@" diff --git a/upload b/upload index e7feeb9..28663a8 100644 --- a/upload +++ b/upload @@ -1,5 +1,12 @@ #!/bin/bash +# Upload a file or directory to the internet and display the URL in the terminal +# Usage: upload +# ... | upload +# +# Author: Nathan Woodburn + + upload() { if [ $# -eq 0 ]; then echo "No arguments specified."