From 170e369a5333f2256ea713f3590540ff44413d47 Mon Sep 17 00:00:00 2001 From: Andy Oknen Date: Wed, 30 Jul 2025 07:40:05 +0000 Subject: [PATCH] Refactor Dockerfile to enhance Oh My Zsh installation and configuration for improved terminal experience --- contrib/docker/devcontainer/Dockerfile | 24 ++++++++++------- contrib/docker/devcontainer/zshrc | 37 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 contrib/docker/devcontainer/zshrc diff --git a/contrib/docker/devcontainer/Dockerfile b/contrib/docker/devcontainer/Dockerfile index 02d74057..d643dcee 100644 --- a/contrib/docker/devcontainer/Dockerfile +++ b/contrib/docker/devcontainer/Dockerfile @@ -11,9 +11,6 @@ RUN apt-get update && apt-get install -y \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# Install Oh My Zsh for better terminal experience -RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended - # Install essential Go development tools only RUN go install golang.org/x/tools/gopls@latest \ && go install github.com/go-delve/delve/cmd/dlv@latest \ @@ -47,15 +44,24 @@ RUN chown $USERNAME:$USERNAME /workspace COPY go.mod go.sum ./ RUN go mod download && chown -R $USERNAME:$USERNAME /workspace +# Install Oh My Zsh for better terminal experience +RUN sh -c "ZSH=/usr/local/share/zsh/oh-my-zsh $(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended \ + && ZSH_CUSTOM=/usr/local/share/zsh/oh-my-zsh/custom \ + && git clone https://github.com/chrissicool/zsh-256color $ZSH_CUSTOM/plugins/zsh-256color \ + && git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions \ + && git clone https://github.com/popstas/zsh-command-time.git $ZSH_CUSTOM/plugins/command-time + +# Setup zshrc +COPY contrib/docker/devcontainer/zshrc /usr/local/share/zsh/.zshrc +RUN rm -f /root/.zshrc \ + && ln -s /usr/local/share/zsh/.zshrc /root/.zshrc \ + && ln -s /usr/local/share/zsh/.zshrc /home/vscode/.zshrc + # Set up shell environment for vscode user USER $USERNAME + +# Set up shell environment for vscode user ENV SHELL=/bin/zsh -RUN echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc \ - && echo 'export GO111MODULE=on' >> ~/.zshrc \ - && echo 'export LANG=C.UTF-8' >> ~/.zshrc \ - && echo 'export LC_ALL=C.UTF-8' >> ~/.zshrc \ - && echo 'export LC_CTYPE=C.UTF-8' >> ~/.zshrc \ - && mkdir -p ~/.cache # Expose common ports that might be used by Yggdrasil EXPOSE 9001 9002 9003 diff --git a/contrib/docker/devcontainer/zshrc b/contrib/docker/devcontainer/zshrc new file mode 100644 index 00000000..a340ee1b --- /dev/null +++ b/contrib/docker/devcontainer/zshrc @@ -0,0 +1,37 @@ +export ZSH="/usr/local/share/zsh/oh-my-zsh" + +ZSH_THEME="agnoster" +CASE_SENSITIVE="true" +zstyle ':omz:update' mode disabled # disable automatic updates +DISABLE_UNTRACKED_FILES_DIRTY="true" +HIST_STAMPS="mm/dd/yyyy" +plugins=(git zsh-256color zsh-autosuggestions command-time sudo) + +ZSH_DISABLE_COMPFIX=true +ZSH_CACHE_DIR="$HOME/.cache/ohmyzsh" +ZSH_COMPDUMP="${ZSH_CACHE_DIR}/.zcompdump-${HOST/.*/}-${ZSH_VERSION}" +mkdir -p "$ZSH_CACHE_DIR" + +source $ZSH/oh-my-zsh.sh + +alias zshconfig="mate ~/.zshrc" +alias ohmyzsh="mate ~/.oh-my-zsh" + +prompt_context() { + _bg=043 + [[ $UID -eq 0 ]] && _bg=202 + prompt_segment $_bg $CURRENT_FG "%m" +} + +prompt_status() { + local -a symbols + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +export PATH=$PATH:$(go env GOPATH 2>/dev/null)/bin +export GO111MODULE=on +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 +export LC_CTYPE=C.UTF-8