parent
76840937d1
commit
fbf4141fb3
2 changed files with 12 additions and 3 deletions
|
@ -1,7 +1,14 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
COMMANDS_PREFIX = 'cd-'
|
||||||
|
|
||||||
|
|
||||||
|
def cd_list_environment:
|
||||||
|
for variable, value in os.environ:
|
||||||
|
print(variable, value)
|
||||||
|
|
||||||
|
|
||||||
def install_commands(path):
|
def install_commands(path):
|
||||||
user = '/usr/local/bin'
|
user = '/usr/local/bin'
|
||||||
for command in ['list-environment']:
|
for command in ['list-environment']:
|
||||||
os.symlink(path, os.path.join(user, f'cd-{command}'))
|
os.symlink(path, os.path.join(user, f'{COMMANDS_PREFIX}{command}'))
|
||||||
|
|
|
@ -7,9 +7,11 @@ import cd
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
command, *_ = sys.argv
|
command, *arguments = sys.argv
|
||||||
command = os.path.basename(command)
|
command = os.path.basename(command)
|
||||||
if command == '__main__.py':
|
if command == '__main__.py':
|
||||||
cd.install_commands(__file__)
|
cd.install_commands(__file__)
|
||||||
else:
|
else:
|
||||||
print(command)
|
command = command.replace('-', '_')
|
||||||
|
function = getattr(cd, command)
|
||||||
|
function(*arguments)
|
||||||
|
|
Loading…
Reference in a new issue