From e27f66e569429a600980cca430e1a36f53389fc7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 26 Apr 2024 23:24:46 +0200 Subject: [PATCH] command --- cd/__init__.py | 6 ++++-- cd/__main__.py | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cd/__init__.py b/cd/__init__.py index 61b0830..bc54d6a 100644 --- a/cd/__init__.py +++ b/cd/__init__.py @@ -1,5 +1,7 @@ import os -def install_commands(): - os.symlink(__file__, '/usr/local/bin/cd-list-environment') +def install_commands(path): + user = '/usr/local/bin' + for command in ['list-environment']: + os.symlink(path, os.path.join(user, f'cd-{command}') diff --git a/cd/__main__.py b/cd/__main__.py index 7835eef..50e77b6 100755 --- a/cd/__main__.py +++ b/cd/__main__.py @@ -8,7 +8,8 @@ import cd if __name__ == '__main__': command, *_ = sys.argv - print(command) command = os.path.basename(command) - print(command) - cd.install_commands() + if command == '__main__.py': + cd.install_commands(__file__) + else: + print(command)