Holger Frey
2 years ago
2 changed files with 28 additions and 5 deletions
@ -0,0 +1,22 @@ |
|||||||
|
""" create a nice path representation from a copied windows path """ |
||||||
|
|
||||||
|
import click |
||||||
|
import pyperclip |
||||||
|
|
||||||
|
REPLACEMENTS = { |
||||||
|
"G:": "Google Drive", |
||||||
|
} |
||||||
|
|
||||||
|
def replace(segment, replacements=REPLACEMENTS): |
||||||
|
return replacements.get(segment, segment) |
||||||
|
|
||||||
|
|
||||||
|
@click.command() |
||||||
|
@click.option("--separator", default=" / ") |
||||||
|
def make_nice_path(separator): |
||||||
|
ugly_path = pyperclip.paste() |
||||||
|
ugly_segments = ugly_path.split("\\") |
||||||
|
pretty_segments = [replace(segment) for segment in ugly_segments] |
||||||
|
pretty_path = separator.join(pretty_segments) |
||||||
|
pyperclip.copy(pretty_path) |
||||||
|
click.echo(f"Copied path '{pretty_path}' to clipboard", err=True) |
Loading…
Reference in new issue