@zendeavor points out that it is confusing to users that chruby_auto is invoked before the command is executed and before the prompt is printed. If user's (ex: @jc00ke) include $RUBY_ENGINE and $RUBY_VERSION in their $PS1, then these values wont be updated until the command after the cd command is executed. @zendeavor recommends using different hooking strategies for interactive vs. non-interactive modes.
Interactive
- bash:
PROMPT_COMMAND
- zsh:
precmd_functions
- ksh:
PS1
Non-interactive
- bash:
trap DEBUG
- zsh:
preexec_functions
- ksh:
trap DEBUG
This would invoke chruby_auto before PS1 is rendered in interactive mode, but invoke chruby_auto before the command is even executed in non-interactive mode.
@zendeavor points out that it is confusing to users that
chruby_autois invoked before the command is executed and before the prompt is printed. If user's (ex: @jc00ke) include$RUBY_ENGINEand$RUBY_VERSIONin their$PS1, then these values wont be updated until the command after thecdcommand is executed. @zendeavor recommends using different hooking strategies for interactive vs. non-interactive modes.Interactive
PROMPT_COMMANDprecmd_functionsPS1Non-interactive
trap DEBUGpreexec_functionstrap DEBUGThis would invoke
chruby_autobeforePS1is rendered in interactive mode, but invokechruby_autobefore the command is even executed in non-interactive mode.