mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-29 13:26:30 -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 remove
|
||||
@@ -9,6 +11,13 @@ from sys import argv
|
||||
import random
|
||||
import string
|
||||
|
||||
# external modules
|
||||
|
||||
import pyperclip
|
||||
|
||||
|
||||
# custom modules
|
||||
|
||||
|
||||
def clear():
|
||||
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 = 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
|
||||
|
||||
@@ -82,6 +91,7 @@ if argument == 'help' or argument == '--help' or argument == '-h':
|
||||
print('add add an entry')
|
||||
print('gen generate a new password')
|
||||
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('sync/-s manually sync the entry directory via rsync')
|
||||
print()
|
||||
@@ -503,6 +513,25 @@ if argument == 'edit note' or argument == 'edit -n':
|
||||
encrypt()
|
||||
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
|
||||
|
||||
if argument == 'gen':
|
||||
@@ -9,6 +9,7 @@ making any major changes in the future.
|
||||
|
||||
New features:
|
||||
|
||||
- added initial clipboard (password copy) support
|
||||
**overhaul error messages using exceptions
|
||||
**add exceptions for unknown arguments
|
||||
**make clean, colorful file list by exporting to document and removing extensions
|
||||
|
||||
Reference in New Issue
Block a user