feat: Add copy command
This commit is contained in:
parent
872910ca3c
commit
98507e35b7
22
README.md
22
README.md
@ -16,5 +16,25 @@ upload <file>
|
|||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
```sh
|
```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
32
copy
Normal 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
7
upload
@ -1,5 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/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() {
|
upload() {
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
echo "No arguments specified."
|
echo "No arguments specified."
|
||||||
|
Loading…
Reference in New Issue
Block a user