mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 16:47:14 -04:00
initial clipboard support
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
# internal modules
|
||||||
|
|
||||||
from os import system
|
from os import system
|
||||||
from os import remove
|
from os import remove
|
||||||
@@ -9,6 +11,13 @@ from sys import argv
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
# external modules
|
||||||
|
|
||||||
|
import pyperclip
|
||||||
|
|
||||||
|
|
||||||
|
# custom modules
|
||||||
|
|
||||||
|
|
||||||
def clear():
|
def clear():
|
||||||
print("\n" * 100)
|
print("\n" * 100)
|
||||||
@@ -49,7 +58,7 @@ def rsyncdown():
|
|||||||
# argument - filter the argument to usable text - some replacements are only done once to prevent interference
|
# argument - filter the argument to usable text - some replacements are only done once to prevent interference
|
||||||
|
|
||||||
argument = str(argv).replace('[', '', 1).replace(']', '', 1).replace(',', '').replace("'", '') \
|
argument = str(argv).replace('[', '', 1).replace(']', '', 1).replace(',', '').replace("'", '') \
|
||||||
.replace(' ', '', 1).replace('/usr/bin/', '', 1).replace('rpass', '', 1).replace('./', '', 1).replace('.py', '', 1)
|
.replace(' ', '', 1).replace('/usr/bin/', '', 1).replace('rpass', '', 1)
|
||||||
|
|
||||||
# startup help
|
# startup help
|
||||||
|
|
||||||
@@ -82,6 +91,7 @@ if argument == 'help' or argument == '--help' or argument == '-h':
|
|||||||
print('add add an entry')
|
print('add add an entry')
|
||||||
print('gen generate a new password')
|
print('gen generate a new password')
|
||||||
print('edit edit an existing entry')
|
print('edit edit an existing entry')
|
||||||
|
print('copy copy the password of an entry to your clipboard')
|
||||||
print('remove/-rm delete an existing entry')
|
print('remove/-rm delete an existing entry')
|
||||||
print('sync/-s manually sync the entry directory via rsync')
|
print('sync/-s manually sync the entry directory via rsync')
|
||||||
print()
|
print()
|
||||||
@@ -503,6 +513,25 @@ if argument == 'edit note' or argument == 'edit -n':
|
|||||||
encrypt()
|
encrypt()
|
||||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||||
|
|
||||||
|
# copy
|
||||||
|
|
||||||
|
if argument == 'copy':
|
||||||
|
print()
|
||||||
|
term('cd ~/.rpass-store; ls -1 *')
|
||||||
|
print()
|
||||||
|
readentry = str(input('Entry to copy: '))
|
||||||
|
# generate random strings for /dev/shm
|
||||||
|
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
||||||
|
for _ in range(random.randint(10, 30)))
|
||||||
|
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
||||||
|
for _ in range(random.randint(10, 30)))
|
||||||
|
term('mkdir -p /dev/shm/' + shmfolder)
|
||||||
|
# end string and folder generation
|
||||||
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||||
|
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||||
|
pyperclip.copy(copyline[1].replace('\n', ''))
|
||||||
|
print()
|
||||||
|
|
||||||
# gen
|
# gen
|
||||||
|
|
||||||
if argument == 'gen':
|
if argument == 'gen':
|
||||||
@@ -9,6 +9,7 @@ making any major changes in the future.
|
|||||||
|
|
||||||
New features:
|
New features:
|
||||||
|
|
||||||
|
- added initial clipboard (password copy) support
|
||||||
**overhaul error messages using exceptions
|
**overhaul error messages using exceptions
|
||||||
**add exceptions for unknown arguments
|
**add exceptions for unknown arguments
|
||||||
**make clean, colorful file list by exporting to document and removing extensions
|
**make clean, colorful file list by exporting to document and removing extensions
|
||||||
|
|||||||
Reference in New Issue
Block a user