busybox ps1 profile colors
The default prompt of BusyBox ash shell looks a bit old fashioned . But thanks to nearly full support of the
PS1 environment variable you can customize the prompt to match your needs.
Customizing the PS1 variable is quite simple: just add
/etc/profile which is read automatically by ash when it’s used as login shell:
# If not running interactively, don't do anything [ -z "$PS1" ] && return # set a fancy prompt (non-color, overwrite the one in /etc/profile) if [ $(id -u) -eq 0 ]; then # root user export PS1='\n\e[31m\e[1m\u@\h\e[0m \e[94m\w\n \e[31m\e[1m#\e[0m\e[0m\e[39m\e[49m ' else # non root export PS1='\n\e[92m\e[1m\u@\h\e[0m \e[94m\w\n \e[92m\e[1m$\e[0m\e[0m\e[39m\e[49m ' fi # shortcuts alias la='ls $LS_OPTIONS -all -h'
Within Docker or any containers#
As mentioned above, the /etc/profile file is only parsed for login shells. To use it within docker you have to explicitly pass the
ENV environment variable. This forces ash to read the file.
FROM scratch as merge # use /etc/profile ENV ENV="/etc/profile" # set busybox as default entrypoint ENTRYPOINT [ "/usr/bin/busybox", "ash" ]