feat: Add copy command

This commit is contained in:
Nathan Woodburn 2023-10-13 11:35:53 +11:00
parent 872910ca3c
commit 98507e35b7
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
3 changed files with 60 additions and 1 deletions

View File

@ -16,5 +16,25 @@ upload <file>
### 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 <file>
```
### 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
```

32
copy Normal file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# Copy file contents to clipboard
# Usage: copy <file>
# ... | copy <file_name>
#
# Author: Nathan Woodburn
copy() {
if [ $# -eq 0 ]; then
echo "No arguments specified."
echo "Usage: copy <file>"
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 "$@"

7
upload
View File

@ -1,5 +1,12 @@
#!/bin/bash
# Upload a file or directory to the internet and display the URL in the terminal
# Usage: upload <file|directory>
# ... | upload <file_name>
#
# Author: Nathan Woodburn
upload() {
if [ $# -eq 0 ]; then
echo "No arguments specified."