Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting PS1 after posix shell initialisation breaks directory registering #939

Open
kalocsaibotond opened this issue Nov 21, 2024 · 2 comments

Comments

@kalocsaibotond
Copy link

Having a shell startup command like

...
eval "$(zoxide init posix --hook prompt)"
...
PS1='[\u@\h \W]\$'
...

for a posix shell will break zoxide's directory registering capability (for zoxide 0.9.6 ). I tried this out for bash 5.2.32(1) and dash 0.5.12_2 . This is not the case for bash initialisation. After eval "$(zoxide init bash)" setting PS1 will not interfere with zoxide.

I surmise, hence the requirement to put zoxide initialisation as the last startup command.

Nevertheless, this is problematic if I want to set zoxide to be a system-wide available tool, since conventionally, I have to initialise zoxide somewhere in /etc .
If a user sets PS1 then that user inadvertently breaks his access to zoxide.

@ajeetdsouza
Copy link
Owner

Yes, the README mentions initializing zoxide last for exactly this reason. Is there an alternate solution you're proposing?

@ajeetdsouza ajeetdsouza added the waiting-for-response Waiting for a response from the issue author. label Nov 21, 2024
@kalocsaibotond
Copy link
Author

kalocsaibotond commented Nov 22, 2024

I do not have a better idea for the implementation. However, since zoxide explicitly use the contents of PS1, zoxide ought to raise a warning, when the contents of PS1 is not adequate for proper operation. So for example zoxide ought to raise a warning, after using z or zi.
Having such a warning, the user would be notified how zoxide use PS1, and hence the user can bypass the problem, via setting the PS1 in such a way to preserve zoxide's part (for example with sed-ing out the shell default part of PS1).

@github-actions github-actions bot removed the waiting-for-response Waiting for a response from the issue author. label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants