Skip to content

Commit

Permalink
Add -x to skip dependency installation (#19)
Browse files Browse the repository at this point in the history
* Add -x to  skip dependency installation

Signed-off-by: Chaichontat Sriworarat <34997334+chaichontat@users.noreply.github.com>

* Update README

Signed-off-by: Chaichontat Sriworarat <34997334+chaichontat@users.noreply.github.com>
Co-authored-by: Deluan <deluan@deluan.com>
  • Loading branch information
chaichontat and deluan committed Jan 13, 2023
1 parent 946cec3 commit e40ded4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ One line installation: add the following line in your `Dockerfile`:

```Dockerfile
# Default powerline10k theme, no plugins installed
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)"
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)"
```

#### Optional arguments:
Expand All @@ -33,23 +33,26 @@ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/
- `-a <line>` - You can add extra lines at the end of the generated `.zshrc` (but before loading oh-my-zsh) by
passing one `-a` argument for each line you want to add. This is useful to customize plugins or themes.
For example, if you want to enable [case sensitive completion](https://stackoverflow.com/a/28021691):

- `-x` - Skip installation of dependencies: `zsh`, `git`, `curl`. If you are having issues with the script failing to
install these dependencies due to sudo permissions, you can install them yourself in a prior step, and use this flag
to make the script skip their installation

```Dockerfile
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
-a 'CASE_SENSITIVE="true"'
```

#### Examples:

```Dockerfile
# Uses "robbyrussell" theme (original Oh My Zsh theme), with no plugins
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
-t robbyrussell
```

```Dockerfile
# Uses "git", "ssh-agent" and "history-substring-search" bundled plugins
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
-p git -p ssh-agent -p 'history-substring-search' \
-a 'bindkey "\$terminfo[kcuu1]" history-substring-search-up' \
-a 'bindkey "\$terminfo[kcud1]" history-substring-search-down'
Expand All @@ -58,7 +61,7 @@ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/

```Dockerfile
# Uses "Spaceship" theme with some customization. Uses some bundled plugins and installs some more from github
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.4/zsh-in-docker.sh)" -- \
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
-t https://github.com/denysdovhan/spaceship-prompt \
-a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \
-a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \
Expand All @@ -74,7 +77,8 @@ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/
- This scripts requires `git` and `curl` to work properly. If your `Dockerfile` uses `root` as the
main user, it should be fine, as the script will install them automatically. If you are using a
non-root user, make sure to install the `sudo` package _OR_ to install `git` and `curl` packages
_before_ calling this script
_before_ calling this script. In case `sudo` access is an issue and you already have `zsh`, `git`
and `curl`, you can use the option `-x` to skip the installations.
- By default this script will install the `powerlevel10k` theme, as it is one of the fastest and most
customizable themes available for zsh. If you want the default Oh My Zsh theme, use the option
`-t robbyrussell`
Expand Down
9 changes: 7 additions & 2 deletions zsh-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ set -e
THEME=default
PLUGINS=""
ZSHRC_APPEND=""
INSTALL_DEPENDENCIES=true

while getopts ":t:p:a:" opt; do
while getopts ":t:p:a:x" opt; do
case ${opt} in
t) THEME=$OPTARG
;;
p) PLUGINS="${PLUGINS}$OPTARG "
;;
a) ZSHRC_APPEND="$ZSHRC_APPEND\n$OPTARG"
;;
x) INSTALL_DEPENDENCIES=false
;;
\?)
echo "Invalid option: $OPTARG" 1>&2
;;
Expand Down Expand Up @@ -137,7 +140,9 @@ POWERLEVEL9K_STATUS_CROSS=true
EOM
}

install_dependencies
if [ "$INSTALL_DEPENDENCIES" = true ]; then
install_dependencies
fi

cd /tmp

Expand Down

0 comments on commit e40ded4

Please sign in to comment.