Last active
August 29, 2015 14:05
-
-
Save muffinresearch/255def06571d8e797f36 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# -*- coding: utf-8 -*- | |
"""Simple command that prints out the current n last levels of the CWD | |
replacing the prefix with a horizontal ellipsis | |
Usage pwdn [numdirs] | |
""" | |
from os import getcwd | |
from sys import argv, exit | |
try: | |
numdir = (len(argv) > 1) and int(argv[1]) or 2 | |
except ValueError: | |
print "Usage: pwdn [numdirs]" | |
exit(1) | |
cwd = getcwd()[1:].split("/") | |
print "%s%s" % (len(cwd) > numdir and "…/" or "/", '/'.join(cwd[-numdir:])) | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment