Merge pull request #383 from SiddheshKukade/master

Feature Request : Copy to Clipboard form file
This commit is contained in:
Advaita Saha 2022-10-14 22:31:43 +05:30 committed by GitHub
commit 153f7411dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 33 deletions

View File

@ -80,14 +80,21 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<sub><b>Agnish Ghosh</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/SiddheshKukade">
<img src="https://avatars.githubusercontent.com/u/65951872?v=4" width="100;" alt="SiddheshKukade"/>
<br />
<sub><b>Siddhesh Bhupendra Kuakde</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/rahulkarda">
<img src="https://avatars.githubusercontent.com/u/76204863?v=4" width="100;" alt="rahulkarda"/>
<br />
<sub><b>Rahul Karda</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/muratonuryildirim">
<img src="https://avatars.githubusercontent.com/u/77264793?v=4" width="100;" alt="muratonuryildirim"/>
@ -122,6 +129,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<br />
<sub><b>Abhishek Kushwaha</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/Khushi260">
<img src="https://avatars.githubusercontent.com/u/94845508?v=4" width="100;" alt="Khushi260"/>
<br />
<sub><b>Khushi Jha</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/yunghog">
@ -129,8 +144,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<br />
<sub><b>YUNGH OG</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/Farhan-2222">
<img src="https://avatars.githubusercontent.com/u/87274221?v=4" width="100;" alt="Farhan-2222"/>
@ -152,26 +166,12 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<sub><b>Raihan Khan</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/SiddheshKukade">
<img src="https://avatars.githubusercontent.com/u/65951872?v=4" width="100;" alt="SiddheshKukade"/>
<br />
<sub><b>Siddhesh Bhupendra Kuakde</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/ArshErgon">
<img src="https://avatars.githubusercontent.com/u/40994679?v=4" width="100;" alt="ArshErgon"/>
<br />
<sub><b>Mohd Arsh Ali </b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Khushi260">
<img src="https://avatars.githubusercontent.com/u/94845508?v=4" width="100;" alt="Khushi260"/>
<br />
<sub><b>Khushi Jha</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
@ -489,6 +489,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<sub><b>Arijit Ghosh</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Yaswanth820">
<img src="https://avatars.githubusercontent.com/u/55750562?v=4" width="100;" alt="Yaswanth820"/>
<br />
<sub><b>Balaji Yaswanth Vankala</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Danuragtiwari">
<img src="https://avatars.githubusercontent.com/u/86867000?v=4" width="100;" alt="Danuragtiwari"/>
@ -509,15 +516,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<br />
<sub><b>Heshanthaka</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/Gokul-Ks">
<img src="https://avatars.githubusercontent.com/u/73174047?v=4" width="100;" alt="Gokul-Ks"/>
<br />
<sub><b>Gokul_Zuzu</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/KuSantosh100">
<img src="https://avatars.githubusercontent.com/u/97560663?v=4" width="100;" alt="KuSantosh100"/>
@ -552,15 +559,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<br />
<sub><b>Raj Saha </b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/ramonsaraiva">
<img src="https://avatars.githubusercontent.com/u/5559120?v=4" width="100;" alt="ramonsaraiva"/>
<br />
<sub><b>Ramon Saraiva</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/riyajaiswal25">
<img src="https://avatars.githubusercontent.com/u/84279900?v=4" width="100;" alt="riyajaiswal25"/>
@ -595,15 +602,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<br />
<sub><b>Anjali Chauhan</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/anshrusia200">
<img src="https://avatars.githubusercontent.com/u/85791796?v=4" width="100;" alt="anshrusia200"/>
<br />
<sub><b>Ansh Rusia</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/arpitbhardwaj">
<img src="https://avatars.githubusercontent.com/u/23013825?v=4" width="100;" alt="arpitbhardwaj"/>
@ -638,15 +645,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<br />
<sub><b>Null</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/yashbrid03">
<img src="https://avatars.githubusercontent.com/u/65955929?v=4" width="100;" alt="yashbrid03"/>
<br />
<sub><b>Yash Nilesh Brid</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/mclmza">
<img src="https://avatars.githubusercontent.com/u/7353871?v=4" width="100;" alt="mclmza"/>
@ -681,15 +688,15 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
<br />
<sub><b>Prathamesh Nayak</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/smit-sms">
<img src="https://avatars.githubusercontent.com/u/52400400?v=4" width="100;" alt="smit-sms"/>
<br />
<sub><b>Smit Shah</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/SameerSahu007">
<img src="https://avatars.githubusercontent.com/u/29480670?v=4" width="100;" alt="SameerSahu007"/>

View File

@ -0,0 +1,6 @@
# Copy to Clipboard
A tool that will help you to copy the contents of a file having any size without opening that file
## Usage/Examples
```sh
$ clipboard.py <fileName>
```

View File

@ -0,0 +1,29 @@
import os
import sys
import platform
import subprocess
# Seeing if the file exists
if os.path.exists(sys.argv[1]):
# Open Only if the file exists on the computer
f = open(sys.argv[1], "r")
# Storing the Content of the file in the f_contents variable
f_contents = f.read()
# closing the opened file
f.close()
else:
# If the file Doesn't Exists
print("File Not found : copy2clip <file_name>")
exit(1)
# Storing the current OS version
whatos = platform.system()
# If Darwin or Ubuntu
if whatos == "Darwin":
subprocess.run("pbcopy", universal_newlines=True, input=f_contents)
print("success: copied to clipboard")
# If Windows
elif whatos == "Windows":
subprocess.run("clip", universal_newlines=True, input=f_contents)
print("success: copied to clipboard")
else:
print("failed: clipboard not supported")