Skip to content

Commit 3372bcf

Browse files
authored
Merge pull request #6001 from thaJeztah/tweak_prompt
Dockerfile: fix and clean up shell prompt
2 parents c528504 + 1f9a55d commit 3372bcf

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

dockerfiles/Dockerfile.dev

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,28 @@ RUN apk add --no-cache \
4747
jq \
4848
nano
4949

50-
RUN echo -e "\nYou are now in a development container. Run '\e\033[1mmake help\e\033[0m' to learn about\navailable make targets.\n" > /etc/motd \
51-
&& echo -e "cat /etc/motd\nPS1=\"\e[0;32m\u@docker-cli-dev\\$ \e[0m\"" >> /root/.bashrc \
52-
&& echo -e "source /etc/bash/bash_completion.sh" >> /root/.bashrc
50+
RUN <<-'EOF'
51+
cat > /etc/motd <<-'EOM'
52+
\e[1;32mYou are now in a development container.\e[0m
53+
54+
Run \e[1;36mmake help\e[0m to see available targets.
55+
EOM
56+
57+
cat >> /root/.bashrc <<-'EOB'
58+
# print the MOTD when opening the dev-container (interactive shell only).
59+
if [[ $- == *i* ]] && [[ -z "$MOTD_SHOWN" ]]; then
60+
printf "%b\n" "$(cat /etc/motd)"
61+
export MOTD_SHOWN=1
62+
fi
63+
64+
# set a custom prompt to make it more visible when inside the dev-container.
65+
PS1='\[\e[0;32m\]\u@docker-cli-dev\$ \[\e[0m\]'
66+
67+
# set-up bash completion for testing.
68+
source /etc/bash/bash_completion.sh
69+
EOB
70+
EOF
71+
5372
CMD ["/bin/bash"]
5473
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
5574
ENV PATH=$PATH:/go/src/github.com/docker/cli/build

0 commit comments

Comments
 (0)