Skip to content

Instantly share code, notes, and snippets.

@kecs
Created December 6, 2019 23:04
Show Gist options
  • Save kecs/e6fd495b3d1974ce4cae052f410d545e to your computer and use it in GitHub Desktop.
Save kecs/e6fd495b3d1974ce4cae052f410d545e to your computer and use it in GitHub Desktop.
Clipboard helper for people who paste a lot
import sys, re, time
import pyperclip
texts = []
while 1:
sys.stdout.flush()
for i, t in enumerate(texts):
print(f'[{i + 1}] {t}')
inp = input('[*] Press 1-9 to copy to clipboard, q to quit or enter text to store:')
if not inp.strip():
continue
if inp == 'q':
sys.exit(0)
if re.match('\d', inp):
try:
pyperclip.copy(texts[int(inp) - 1])
except IndexError:
print('[*] No such index!')
time.sleep(1)
else:
texts.append(inp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment