deluan / zsh-in-docker

Install Zsh, Oh-My-Zsh and plugins inside a Docker container with one line!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Q: use existing powerlevel10k config and install needed fonts

Norfeldt opened this issue · comments

This project is fantastic. Don't want to miss oh-my-zsh when working in docker and this does this trick.

You wouldn't happen to know the best way to transfer my powerlevel10k config (it's the .p10k.zsh, right?) and install the minimum required fonts (some icons look odd)?

I found a way 👍

# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1

ADD .devcontainer/zsh-in-docker.sh .
RUN sh -c "$(cat zsh-in-docker.sh)" -- \
  -p git \
  -p https://github.com/zsh-users/zsh-autosuggestions \
  -p https://github.com/zsh-users/zsh-completions \
  -p https://github.com/zsh-users/zsh-history-substring-search \
  -p https://github.com/zsh-users/zsh-syntax-highlighting \
  -p 'history-substring-search' \
  -a 'bindkey "\$terminfo[kcuu1]" history-substring-search-up' \
  -a 'bindkey "\$terminfo[kcud1]" history-substring-search-down' 
ADD .devcontainer/.zshrc root
ADD .devcontainer/.p10k.zsh root

# Install pip requirements
ADD requirements.txt .
RUN python -m pip install -r requirements.txt

WORKDIR /app
ADD . /app

ENTRYPOINT [ "/bin/zsh" ]

Hey, glad you liked it :)

As you already found out, you can override the .zshrc file. In that case, you don't need the -a lines, as you are overriding the whole thing.

Another way could be to add just the line to load .p10k.zsh from .zshrc without overriding the whole file:

RUN sh -c "$(cat zsh-in-docker.sh)" -- \
...
  -a 'source ~/.p10k.zsh'

ADD .devcontainer/.p10k.zsh root

Re: fonts, it usually works out-of-box for me, I just have to install fonts on my host machine.

I'm closing this for now, but feel free to reopen in case you are still having trouble with this.