diff --git a/oks_cli/utils.py b/oks_cli/utils.py index 7a2df97..feafc5e 100644 --- a/oks_cli/utils.py +++ b/oks_cli/utils.py @@ -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": @@ -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 diff --git a/tests/test_shell_completion.py b/tests/test_shell_completion.py index 3a34cbc..aef0994 100644 --- a/tests/test_shell_completion.py +++ b/tests/test_shell_completion.py @@ -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() @@ -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()