Created
November 29, 2019 08:15
-
-
Save shanehh/13ccfaa1abb6095bd8aaed6f0009ebd5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
from pathlib import Path | |
def exec(cmd: str): | |
os.system(cmd) | |
def copy_to_clip(content: str) -> None: | |
t = 'echo "{}" | xclip -selection clipboard' | |
exec(t.format(content)) | |
def cmd_arg() -> str: | |
import sys | |
if len(sys.argv) < 2: | |
sys.exit( | |
f"Error: expected a arguments") | |
return sys.argv[1] | |
def main(): | |
pwd = Path.cwd() | |
r = pwd.joinpath(cmd_arg()) | |
copy_to_clip(r) | |
print('write "{}" to the clipboard successfully!'.format(r)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment