Skip to content

Commit

Permalink
Allow theme to reference a public git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Sep 11, 2020
1 parent 3344956 commit a8badf6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ USER $USERNAME
# RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.0.2/zsh-in-docker.sh)" -- \
COPY zsh-in-docker.sh /tmp
RUN /tmp/zsh-in-docker.sh \
-t https://github.com/denysdovhan/spaceship-prompt \
-a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \
-a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \
-p git \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/zsh-users/zsh-completions \
Expand Down
4 changes: 2 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_suite() {
docker-compose up -d test-$image_name
docker cp zsh-in-docker.sh zsh-in-docker_test-${image_name}_1:/tmp
docker exec zsh-in-docker_test-${image_name}_1 sh /tmp/zsh-in-docker.sh \
-t agnoster \
-t https://github.com/denysdovhan/spaceship-prompt \
-p git -p git-auto-fetch \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/zsh-users/zsh-completions \
Expand All @@ -31,7 +31,7 @@ test_suite() {
echo "########################################################################################"
echo "Test: zsh 5 was installed" && assert_contain "$VERSION" "zsh 5" "!"
echo "Test: ~/.zshrc was generated" && assert_contain "$ZSHRC" 'ZSH="/root/.oh-my-zsh"' "!"
echo "Test: theme was configured" && assert_contain "$ZSHRC" 'ZSH_THEME="agnoster"' "!"
echo "Test: theme was configured" && assert_contain "$ZSHRC" 'ZSH_THEME="spaceship-prompt/spaceship"' "!"
echo "Test: plugins were configured" && assert_contain "$ZSHRC" 'plugins=(git git-auto-fetch zsh-autosuggestions zsh-completions )' "!"
echo "Test: line 1 is appended to ~/.zshrc" && assert_contain "$ZSHRC" 'CASE_SENSITIVE="true"' "!"
echo "Test: line 2 is appended to ~/.zshrc" && assert_contain "$ZSHRC" 'HYPHEN_INSENSITIVE="true"' "!"
Expand Down
12 changes: 11 additions & 1 deletion zsh-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export ZSH="$_HOME/.oh-my-zsh"
ZSH_THEME="${_THEME}"
plugins=($_PLUGINS)
source \$ZSH/oh-my-zsh.sh
EOM
printf "$ZSHRC_APPEND"
printf "\nsource \$ZSH/oh-my-zsh.sh"
}

powerline10k_config() {
Expand Down Expand Up @@ -136,6 +136,16 @@ for plugin in $PLUGINS; do
plugin_list="${plugin_list}$plugin_name "
done

# Handle themes
if [ "`echo $THEME | grep -E '^http.*'`" != "" ]; then
theme_repo=`basename $THEME`
THEME_DIR="$HOME/.oh-my-zsh/custom/themes/$theme_repo"
git clone $THEME $THEME_DIR
theme_name=`cd $THEME_DIR; ls *.zsh-theme | head -1`
theme_name="${theme_name%.zsh-theme}"
THEME="$theme_repo/$theme_name"
fi

# Generate .zshrc
zshrc_template "$HOME" "$THEME" "$plugin_list" > $HOME/.zshrc

Expand Down

0 comments on commit a8badf6

Please sign in to comment.