Skip to content

Instantly share code, notes, and snippets.

@MAGANER
Created July 7, 2021 20:05
Show Gist options
  • Save MAGANER/272a8affe4fa07105cbde864756f4d92 to your computer and use it in GitHub Desktop.
Save MAGANER/272a8affe4fa07105cbde864756f4d92 to your computer and use it in GitHub Desktop.
i just need to run several terminals in the same directory, so i wrote this script to get current dir and paste it to clipboard, but also it can put whole file to clipboard.
#for Windows
import pathlib
import sys
import os
curr_path = pathlib.Path().resolve()
def copy2cb(data):
with open(".ts","w") as f:
f.write(str(data))
os.system("clip < .ts")
os.system("erase .ts")
if len(sys.argv) == 1:
copy2cb(curr_path)
elif len(sys.argv) == 2:
with open(sys.argv[1],"rb") as f:
copy2cb(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment