Skip to content

Commit 96e184c

Browse files
committed
Modified script for Linux support and added requirements.txt
1 parent 8e67a3c commit 96e184c

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

scripts/Copy to clipboard/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
```
55
git clone [email protected]:GDSC-RCCIIT/General-Purpose-Scripts.git
66
```
7-
2. Navigate to `Copy to clipboard` directory
7+
2. Install the script requirements
8+
```
9+
pip install -r requirements.txt
10+
```
11+
3. Navigate to `Copy to clipboard` directory
812
```
913
cd General-Purpose-Scripts/scripts/Copy to clipboard
1014
```
11-
3. Run the script to copy text from the desired file to your clipboard
15+
4. Run the script to copy text from the desired file to your clipboard
1216
```
1317
python clipboard.py <file_name>
1418
```
1519
### Note
1620
Replace <file_name> with the name of the file present in the same directory as the script or replace it with the path of the file.
21+
For Linux users, install [xclip](https://linoxide.com/copy-paste-commands-output-xclip-linux/) in your system before running the script.

scripts/Copy to clipboard/clipboard.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import platform
44
import subprocess
5+
import pyperclip
56

67
# Seeing if the file exists
78
if os.path.exists(sys.argv[1]):
@@ -18,7 +19,10 @@
1819

1920
if whatos == "Darwin":
2021
subprocess.run("pbcopy", universal_newlines=True, input=f_contents)
21-
print("success: copied to clipboard")
22+
print("Success! Copied to clipboard.")
23+
elif whatos == "Linux":
24+
pyperclip.copy(f_contents)
25+
print("Success! Copied to clipboard.")
2226
elif whatos == "Windows":
2327
subprocess.run("clip", universal_newlines=True, input=f_contents)
2428
print("Success! Copied to clipboard.")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyperclip==1.8.2

0 commit comments

Comments
 (0)