goto
goto copied to clipboard
Goto not working when in WSL and also using zsh
I installed goto recently on WSL. It didn't work from the first try. So I installed it myself in a different directory where I put most of my global scripts. But when I investigated the goto script, I realized that it checks if you have a .bashrc file but also checks if you have .zshrc. However, if it finds .bashrc, it adds the the sourcing script to it and ignore .zshrc. I have tested the script you guys used to decide which file to use and here is the output:
@DESKTOP-C64TQ1G ➜ testingStuff if [ -f ~/.bashrc ]; then
then> echo ".bashrc exists"
then> fi
.bashrc exists
@DESKTOP-C64TQ1G ➜ testingStuff if [ -f ~/.zshrc ]; then
echo ".zshrc exists"
fi
.zshrc exists
@DESKTOP-C64TQ1G ➜ testingStuff if [ -f ~/.bashrc ]; then
echo "bashrc exists"
elif [ -f ~/.zshrc ]; then
echo "zshrc exists"
fi
bashrc exists
I think the correct behavior in this case is to add it to .zshrc since IF zsh is used, it usually ignores .bashrc and uses its own .zshrc .
@ikteru Thanks for the detailed feedback. I will check on it and with some help from contributors (since I don't use ZSH) we should proceed to the suggested changes.
@iridakos
I believe it is mainly the case that .zshrc and .bashrc co-exists as bash is the default shell in many systems and zsh gets added. I think a possible workaround could be to change the if statement in the install script to check whether $SHELL == /bin/bash or $SHELL == /bin/zsh. This would also fix #55 as the cause of the issue is the same :)
@kasperschnack
Thought that too, but turns out that the $SHELL variable points to the login shell of the current user, not the shell running for the current user.
In my Linux machine I use zsh as my normal shell but for sudo it is bash, and the install script must be run in sudo mode so $SHELL is always bash when I run the script.
We can parse /etc/passwd for the normal shell but i think it would break on Mac and Windows. What do you think @iridakos ?