diff --git a/bin/path-uniq.py b/bin/path-uniq.py new file mode 100755 index 0000000..2d18007 --- /dev/null +++ b/bin/path-uniq.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import select +import os +from sys import stdin, stdout, argv + +if stdin.isatty(): + path = os.environ['PATH'] +else: + path = stdin.readline() + +filtered = [] +parts = path.strip().split(':') +parts.extend(argv[1:]) +for part in parts: + if part not in filtered: + filtered.append(part) +stdout.write(':'.join(filtered) + "\n")