1

I have added the following code to my .bashrc file so that I do not see the path in my terminal.

# Programster Injection
# Here we can choose the mode for displaying the current path in bash terminal.
# 1 = normal path shown
# 2 = only current directory
# 3 = no path at all.
DISPLAY_OPTION=3

if [ "$DISPLAY_OPTION" = 1 ]; then
    PATH_VAR="\w"
elif [ "$DISPLAY_OPTION" = 2 ]; then
    PATH_VAR="\W"
elif [ "$DISPLAY_OPTION" = 3 ]; then
    PATH_VAR=""
fi


if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]'$PATH_VAR'\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:'$PATH_VAR'\$ '
fi

As you can see, the \w in the PS1 environment variable is what is responsible for setting the display of the path. When I open byobu, the PS1 variable is changed from:

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\[\033[00m\]\$

to:

\[\e[38;5;202m\]$(byobu_prompt_status)\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;5m\]\w\[\e[00m\]$(byobu_prompt_symbol)

I actually quite like the rest of the formatting that byobu adds, so how do I make it so that whenever I open byobu, it will now set PS1 to:

PS1='\[\e[38;5;202m\]$(byobu_prompt_status)\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;5m\]\[\e[00m\]$(byobu_prompt_symbol) '

which is the same, but without the \w.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.