Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions oks_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,11 @@ def find_shell_profile(home, shell_type):
if os.path.exists(bash_profile) and os.path.exists(bashrc):
return None

shell_profile = bash_profile or bashrc
if os.path.exists(bash_profile):
shell_profile = bash_profile

if os.path.exists(bashrc):
shell_profile = bashrc

elif shell_type == "zsh":

Expand All @@ -927,7 +931,11 @@ def find_shell_profile(home, shell_type):
if os.path.exists(zshrc) and os.path.exists(profile):
return None

shell_profile = zshrc or profile
if os.path.exists(zshrc):
shell_profile = zshrc

if os.path.exists(profile):
shell_profile = profile

return shell_profile

Expand Down
4 changes: 2 additions & 2 deletions tests/test_shell_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_install_completion_zsh():

result = runner.invoke(cli, ["install-completion", "--type", "zsh"])
assert result.exit_code == 0
assert "Autocompletion installed for zsh" in result.output
assert "To activate autocompletion on login please add following lines into your .profile or .zshrc file" in result.output

completion_file = Path("~/.oks_cli/completions/oks-cli.sh").expanduser()
assert completion_file.exists()
Expand All @@ -22,7 +22,7 @@ def test_install_completion_bash():

result = runner.invoke(cli, ["install-completion", "--type", "bash"])
assert result.exit_code == 0
assert "Autocompletion installed for bash" in result.output
assert "To activate autocompletion on login please add following lines into your .bash_profile or .bashrc file" in result.output

completion_file = Path("~/.oks_cli/completions/oks-cli.sh").expanduser()
assert completion_file.exists()
Expand Down