deluan / zsh-in-docker Goto Github PK
View Code? Open in Web Editor NEWInstall Zsh, Oh-My-Zsh and plugins inside a Docker container with one line!
License: MIT License
Install Zsh, Oh-My-Zsh and plugins inside a Docker container with one line!
License: MIT License
p10k theme takes about 70MB because storing the whole repository git history:
$ du -du -sh ~/.oh-my-zsh/custom/themes/powerlevel10k/.git
74M /home/vscode/.oh-my-zsh/custom/themes/powerlevel10k/.git
$ du -du -sh ~/.oh-my-zsh/custom/themes/powerlevel10k
76M /home/vscode/.oh-my-zsh/custom/themes/powerlevel10k
$ du -sh ~/.oh-my-zsh/
85M /home/vscode/.oh-my-zsh/
IMO you should install oh-my-zsh
and p10k
without cloning a git repository.
First of all, great script! Actually, great project! I love that you have tests.
My issue is when using the up arrow to navigate history, I get no such widget history-substring-search-up
(similar for down arrow)
I was able to "fix" the issue by adding -p history-substring-search
to my Dockerfile.
Seeing as how the default zshrc template includes
bindkey "\$terminfo[kcuu1]" history-substring-search-up
bindkey "\$terminfo[kcud1]" history-substring-search-down
...you might want to also auto include the history-substring-search plugin?
If I am missing something obvious, please educate me. Either way, thanks for sharing this project.
I noticed today when I try to install this in a docker container, I'm getting the following error:
sh: 105: printf: usage: printf format [arg ...]
This is on a "buster" based image, if that matters
How can that be accomplished ?
I would like to have it working for tmux and others services inside the docker as well.
Thanks for this script! I'm a fan of p10k myself and have some custom styling I prefer. I tried adding those lines as -a args but was seeing something different in the final terminal. Here's the snippet from my Dockerfile:
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)" -- \
-t powerlevel10k/powerlevel10k \
-a 'POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon virtualenv anaconda dir vcs newline)' \
-a 'POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION="true"' \
-a 'POWERLEVEL9K_ANACONDA_BACKGROUND="cyan"' \
-a 'POWERLEVEL9K_DIR_BACKGROUND="mediumturquoise"' \
-a 'POWERLEVE9K_MODE="nerdfont-complete"' \
-a 'POWERLEVEL9K_PROMPT_ADD_NEWLINE="true"' \
-a 'alias pip="pip3"' \
-a 'alias ls="ls -GFh"' \
-p git \
-p git-extras \
-p https://github.com/zsh-users/zsh-completions
I am pretty sure it's because of this bit appending to the zshrc and overriding the prompt elements line in mine:
# Install powerlevel10k if no other theme was specified
if [ "$THEME" = "powerlevel10k/powerlevel10k" ]; then
git clone https://github.com/romkatv/powerlevel10k $HOME/.oh-my-zsh/custom/themes/powerlevel10k
powerline10k_config >> $HOME/.zshrc
fi
This happens regardless of if you leave off the -t
flag to use the default or specify powerlevel10k/powerlevel10k. Pretty sure the easiest fix might be to just use a different string for the default value of $THEME and check for that in the if
condition instead! Thanks again!
What about the user password ?
Installing ZSH in a Debian based docker container (jupyter/docker-stacks) with this scripts creates folder and files with wrong permissions.
In the Dockerfile
installing as root user:
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)" -- \
-t bira -p git
Then running /bin/zsh
as a non-root user:
[oh-my-zsh] Insecure completion-dependent directories detected:
drwsrwsr-x. 1 root users 4096 Aug 27 08:18 /home/jovyan/.oh-my-zsh
drwsrwsr-x. 1 root users 8192 Aug 27 08:18 /home/jovyan/.oh-my-zsh/plugins
drwsrwsr-x. 1 root users 45 Aug 27 08:18 /home/jovyan/.oh-my-zsh/plugins/git
[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.
[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh] compaudit | xargs chmod g-w,o-w
[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.
Unfortunately the given compaudit
command to fix the permissions cannot be run in the Dockerfile (it seems to work only when the ZSH shell is active, not available in bash, nor with /bin/zsh -c
)
There might be a oneliner chmod
to fix this, but I thought the goal of such a script was to avoid such basic issues with permissions
When trying to run this command multiple times, let's say rebuilding a container, but not clearing the data from the volume, it throws the following error:
sh -c "$(curl -L https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \ ─╯
-p git \
-p https://github.com/zsh-users/zsh-autosuggestions /home/sail/.oh-my-zsh/custom/plugins/zsh-autosuggestions \
-p https://github.com/MichaelAquilina/zsh-you-should-use /home/sail/.oh-my-zsh/custom/plugins/you-should-use \
-p https://github.com/zsh-users/zsh-syntax-highlighting /home/sail/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \
-p https://github.com/zsh-users/zsh-completions /home/sail/.oh-my-zsh/custom/plugins/zsh-completions
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 3828 100 3828 0 0 4497 0 --:--:-- --:--:-- --:--:-- 7748
Installing Oh-My-Zsh with:
THEME = default
PLUGINS = git https://github.com/zsh-users/zsh-autosuggestions
###### Installing dependencies for ubuntu
/usr/bin/sudo
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:4 https://dl.yarnpkg.com/debian stable InRelease
Hit:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:6 https://deb.nodesource.com/node_18.x jammy InRelease
Hit:7 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease
Hit:8 http://apt.postgresql.org/pub/repos/apt jammy-pgdg InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
zsh is already the newest version (5.8.1-1).
curl is already the newest version (7.81.0-1ubuntu1.6).
git is already the newest version (1:2.34.1-1ubuntu1.5).
locales is already the newest version (2.35-0ubuntu3.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
locales-all is already the newest version (2.35-0ubuntu3.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Generating locales (this might take a while)...
en_US.UTF-8... done
Generation complete.
fatal: destination path '/home/sail/.oh-my-zsh/custom/plugins/zsh-autosuggestions' already exists and is not an empty directory.
Is there a better way to handle this to automatically skip plugins that are already installed? Here is my RUN command:
USER sail
RUN sh -c "$(curl -L https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
-p git \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/MichaelAquilina/zsh-you-should-use \
-p https://github.com/zsh-users/zsh-syntax-highlighting \
-p https://github.com/zsh-users/zsh-completions
USER root
I am using vscode built-in terminal, and when I use this script to create a container, I found the zsh-auto-suggestion is not working properly as the color of the suggestion is wrong:
Then I found it was caused by the env TERM
was set to xterm
.
So I remove the export TERM=xterm
, then echo $TERM
to find that it is xterm-256color
originally.
I wonder why the env 'TERM=xterm' would be set and if there should be an option to disable it.
dockerfile segment:
ARG DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
sudo net-tools iputils-ping iproute2 telnet curl wget nano procps
RUN addgroup www && adduser --shell /bin/zsh --home /home/www --gecos "" --ingroup www --disabled-password www
USER www
# Default powerline10k theme, no plugins installed
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)"
#20 0.833 ###### Installing dependencies for ubuntu
#20 0.837 /usr/bin/sudo
#20 0.854 sudo: no tty present and no askpass program specified
------
executor failed running [/bin/bash -c sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)" -- -p git -p ssh-agent -p z -p autojump -p history -p last-working-dir -p docker -p github -p jsontools -p node -p npm -p golang -p tmux -p tmuxinator -p catimg -p https://github.com/zsh-users/zsh-autosuggestions
-p https://github.com/zsh-users/zsh-completions -p https://github.com/zsh-users/zsh-syntax-highlighting -a 'export ZSH_DISABLE_COMPFIX=true' -a 'HIST_STAMPS="yyyy-mm-dd"' -a 'autoload -U compinit && compinit' -a 'export ZSH_TMUX_AUTOSTART=false' -a 'export ZSH_TMUX_AUTOCONNECT=false' -a 'zstyle :omz:plugins:ssh-agent agent-forwarding on' -a 'if [ -f \$HOME/.myenvset ]; then source \$HOME/.myenvset;fi' -a '[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh' -a 'if [ "\$TERM" = "xterm-256color" ] && [ -z "\$INSIDE_EMACS" ]; then test -e "\${HOME}/.iterm2_shell_integration.zsh" && source "\${HOME}/.iterm2_shell_integration.zsh";fi']: exit code: 1
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 am trying to run the zsh-in-docker script in a docker file like this:
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
-t eastwood -p git -x
You can see I am specifying eastwood
as the theme with the -t
option. This docker file is started with a vscode devcontainer. For some reason - after starting the container the ~/.zshrc file always has this setting for the theme like this:
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="devcontainers"
If I manually change the theme in the .zshrc to eastwood
and source it - then it works great with the selected theme.
There does not seem to be a theme even called "devcontainers" available!?? I also can't see any logic in your script that could do this so its weird!
I've installed the package, but when trying to exec into it I get:
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "zsh": executable file not found in $PATH: unknown
Using:
docker exec -it 6ea4953e2df4 sh
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.