Skip to content

Instantly share code, notes, and snippets.

@shanehh
Created November 29, 2019 08:15
Show Gist options
  • Save shanehh/13ccfaa1abb6095bd8aaed6f0009ebd5 to your computer and use it in GitHub Desktop.
Save shanehh/13ccfaa1abb6095bd8aaed6f0009ebd5 to your computer and use it in GitHub Desktop.
#!/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