Created
June 14, 2012 20:37
-
-
Save davidchambers/2932794 to your computer and use it in GitHub Desktop.
I get the arguments to `ln -s` round the wrong way at least half the time. This simple script makes this relatively common operation easy to get right.
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 python | |
import subprocess | |
import sys | |
args = sys.argv[1:] | |
if args in (['-h'], ['--help'], []): | |
print ''' | |
Usage: symlink path/to/symlink to path/to/existing | |
-h, --help display this help message | |
-v, --version display the version number | |
''' | |
sys.exit() | |
if args in (['-v'], ['--version']): | |
print '0.1.0' | |
sys.exit() | |
try: | |
new, direction, existing = args | |
except ValueError: | |
print 'invalid arguments (`symlink --help` provides usage instructions)' | |
sys.exit() | |
if direction != 'to': | |
print 'invalid arguments (`symlink --help` provides usage instructions)' | |
sys.exit() | |
subprocess.call(('ln', '-s', existing, new)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation