Skip to content

Commit a29e589

Browse files
authored
Merge pull request #37 from wambitz/fix/36/remove-color-enforcing
feat: add TERM environment variable for enhanced terminal color support
2 parents 1b3b71b + ac14848 commit a29e589

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"--hostname", "cpp-devcontainer",
4545
"--name", "cpp-dev-${localEnv:USER}",
4646
"--env", "DISPLAY=${localEnv:DISPLAY}",
47+
"--env", "TERM=xterm-256color",
4748
"--volume", "/tmp/.X11-unix:/tmp/.X11-unix",
4849
"--gpus", "all"
4950
// TODO: Analyze if needed

Dockerfile

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,41 @@ RUN apt-get update && apt-get install -y \
3434

3535
# ------------------------------------------------------------------------------
3636
# Create 'ubuntu' user if it doesn't exist (for Ubuntu 22.04 compatibility)
37+
#
38+
# Ubuntu 24.04 already includes this user; Ubuntu 22.04 does not.
39+
# UID/GID will be remapped at runtime by entrypoint.sh to match host.
40+
#
41+
# IMPORTANT: We hardcode 'ubuntu' to avoid UID conflicts:
42+
# - Ubuntu base images already have an 'ubuntu' user at UID 1000
43+
# - If we used a different username and tried to create it with UID 1000,
44+
# the 'useradd' command would fail due to UID conflict
45+
# - Runtime remapping (via usermod) changes the numeric UID/GID, not the name
46+
# - File permissions use numeric UIDs, so the username is just a label
3747
# ------------------------------------------------------------------------------
3848
RUN if ! id -u ubuntu > /dev/null 2>&1; then \
3949
useradd -m -s /bin/bash -u 1000 ubuntu; \
4050
fi
4151

4252
# ------------------------------------------------------------------------------
43-
# Configure the 'ubuntu' user (UID/GID will be remapped at runtime)
53+
# Configure sudo access for ubuntu user
4454
# ------------------------------------------------------------------------------
4555
RUN echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/ubuntu \
4656
&& chmod 0440 /etc/sudoers.d/ubuntu
4757

4858
# ------------------------------------------------------------------------------
49-
# Configure bash with colors for ubuntu user
59+
# Enable colored terminal prompts (OPTIONAL - forces colors unconditionally)
60+
#
61+
# Without TERM=xterm-256color (set in run.sh and devcontainer.json), TERM
62+
# defaults to "xterm" which lacks color support. Setting TERM=xterm-256color
63+
# enables Ubuntu's .bashrc auto-detection to recognize and use colors.
64+
#
65+
# Uncommenting the line below forces colors unconditionally, bypassing detection.
66+
# This ensures colors work even if TERM isn't properly set, or in non-interactive
67+
# contexts. Safe for modern environments like Ubuntu 22.04/24.04.
68+
#
69+
# Only downside: may show escape codes on very old terminals without color support.
5070
# ------------------------------------------------------------------------------
51-
RUN echo 'export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' >> /home/ubuntu/.bashrc \
52-
&& echo 'alias ls="ls --color=auto"' >> /home/ubuntu/.bashrc \
53-
&& echo 'alias grep="grep --color=auto"' >> /home/ubuntu/.bashrc
71+
# RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /home/ubuntu/.bashrc
5472

5573
# -----------------------------------------------------------------------------
5674
# Install pre-commit for code quality checks

scripts/docker/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ docker run --rm -it \
2828
--env "HOST_UID=$(id -u)" \
2929
--env "HOST_GID=$(id -g)" \
3030
--env "DISPLAY=${DISPLAY}" \
31+
--env TERM=xterm-256color \
3132
--volume /tmp/.X11-unix:/tmp/.X11-unix \
3233
--volume "$PROJECT_ROOT:/workspaces/$PROJECT_NAME" \
3334
--gpus all \

0 commit comments

Comments
 (0)