cfg/bin/short_path

19 lines
346 B
Text
Raw Normal View History

2016-07-21 13:48:49 +00:00
#!/usr/bin/env python
import os
path = os.getcwd()
path = path.replace(os.environ["HOME"], "~")
path_parts = path.split("/")
path = ""
for part in path_parts[:-2]:
if len(part) > 0:
path = "{}/{}".format(path, part[0])
else:
path = "{}/{}".format(path, part)
path = "{}/{}".format(path, "/".join(path_parts[-2:]))
print path[1:]