rcaloras / bash-preexec

⚡ preexec and precmd functions for Bash just like Zsh.
MIT License
862 stars 94 forks source link

Return immediately when running in Zsh #113

Closed FranklinYu closed 3 years ago

FranklinYu commented 3 years ago

This might sound weird, but some users choose to source this script for both Bash and Zsh. I think it doesn’t harm to have something like this in the beginning:

if [[ -n $ZSH_NAME ]]; then
    return
fi
rcaloras commented 3 years ago

@FranklinYu thanks for the feedback! This should already be accounted for in:https://github.com/rcaloras/bash-preexec/blob/7884535ed423ac27d3b6b473c61b1fe41905aca1/bash-preexec.sh#L321-L324 This line should effectively cause this script to exit with 1 when trying to source with zsh or any shell other than Bash. Please let me know if I'm mistaken.

FranklinYu commented 3 years ago

Thank you very much. I have noticed this line, but it is very late in the script. At that time all the functions and variables are already there. How about moving this 4 lines to the top?

rcaloras commented 3 years ago

Noticed this when you first posted, but didn't give it much thought. Thanks for the feedback! Updated in https://github.com/rcaloras/bash-preexec/pull/114 Let me know if you have something else in mind.