Skip to content

Instantly share code, notes, and snippets.

@ai2ys
Created October 26, 2023 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ai2ys/5d473ff42d42ba4e4ed9388de128b81b to your computer and use it in GitHub Desktop.
Save ai2ys/5d473ff42d42ba4e4ed9388de128b81b to your computer and use it in GitHub Desktop.
Terminal Coloring in Docker Container

Terminal Coloring in Docker container

This will look like this but username, @-symbol, hostname, workdir, and $-symbol differently colored.

🐳 username@hostname:/workdir$

Dockerfile

# defining a custom PS1 as build argument
ARG CUSTOM_PS1="'🐳 \[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '"

# Only append if not empty
RUN [ -n "${CUSTOM_PS1}" ] && echo "PS1=${CUSTOM_PS1}" >> $HOME/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment