I am following the direnv wiki on PS1. I have the following relevant entries in my files.
.bashrc
DEFAULT_PS1='\[$(ppwd)\]\u@\h:\w$(__git_ps1 " (%s)")'
# add some more things to DEFAULT_PS1, conditionally
DEFAULT_PS1+='> '
PS1=${CUSTOM_PS1:-$DEFAULT_PS1}
# optional bashrc file extensions
for f in ~/.bashrc_*; do test -s $f && . $f || true; done
eval "$(direnv hook bash)"
.envrc
export KUBECONFIG=~/.config/kube/homelab.yaml
export KUBE_PS1_ENABLED=on
export CUSTOM_PS1='$(kube_ps1) $ '
PATH_add scripts
I have allowed the latest version of the .envrc
with direnv allow
. However, when changing to the directory, the custom PS1 value is not set, although the values seems to be right
$ cd -
/home/robert/sources/oss/sling-cloud-native
direnv: loading .envrc
direnv: export +CUSTOM_PS1 +KUBE_PS1_ENABLED ~KUBECONFIG ~PATH
$ echo $PS1
\[$(ppwd)\]\u@\h:\w$(__git_ps1 " (%s)")$(kube_ps1)>
$ echo $CUSTOM_PS1
$(kube_ps1) $
I am not sure how the solution in the wiki is supposed to work, as apparently the value of PS1 is set to the DEFAULT_PS1 when the .bashrc
file is loaded the first time and is not re-evaluated as part of the direnv
hook.
How can I change the value of PS1 using direnv
?
unset PS1
has to be placed at the bottom of the.envrc
– Christmann