Skip to content

Commit a8badf6

Browse files
committed
Allow theme to reference a public git repo
1 parent 3344956 commit a8badf6

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ USER $USERNAME
2323
# RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.0.2/zsh-in-docker.sh)" -- \
2424
COPY zsh-in-docker.sh /tmp
2525
RUN /tmp/zsh-in-docker.sh \
26+
-t https://github.com/denysdovhan/spaceship-prompt \
27+
-a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \
28+
-a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \
2629
-p git \
2730
-p https://github.com/zsh-users/zsh-autosuggestions \
2831
-p https://github.com/zsh-users/zsh-completions \

test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_suite() {
1515
docker-compose up -d test-$image_name
1616
docker cp zsh-in-docker.sh zsh-in-docker_test-${image_name}_1:/tmp
1717
docker exec zsh-in-docker_test-${image_name}_1 sh /tmp/zsh-in-docker.sh \
18-
-t agnoster \
18+
-t https://github.com/denysdovhan/spaceship-prompt \
1919
-p git -p git-auto-fetch \
2020
-p https://github.com/zsh-users/zsh-autosuggestions \
2121
-p https://github.com/zsh-users/zsh-completions \
@@ -31,7 +31,7 @@ test_suite() {
3131
echo "########################################################################################"
3232
echo "Test: zsh 5 was installed" && assert_contain "$VERSION" "zsh 5" "!"
3333
echo "Test: ~/.zshrc was generated" && assert_contain "$ZSHRC" 'ZSH="/root/.oh-my-zsh"' "!"
34-
echo "Test: theme was configured" && assert_contain "$ZSHRC" 'ZSH_THEME="agnoster"' "!"
34+
echo "Test: theme was configured" && assert_contain "$ZSHRC" 'ZSH_THEME="spaceship-prompt/spaceship"' "!"
3535
echo "Test: plugins were configured" && assert_contain "$ZSHRC" 'plugins=(git git-auto-fetch zsh-autosuggestions zsh-completions )' "!"
3636
echo "Test: line 1 is appended to ~/.zshrc" && assert_contain "$ZSHRC" 'CASE_SENSITIVE="true"' "!"
3737
echo "Test: line 2 is appended to ~/.zshrc" && assert_contain "$ZSHRC" 'HYPHEN_INSENSITIVE="true"' "!"

zsh-in-docker.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ export ZSH="$_HOME/.oh-my-zsh"
100100
ZSH_THEME="${_THEME}"
101101
plugins=($_PLUGINS)
102102
103-
source \$ZSH/oh-my-zsh.sh
104103
EOM
105104
printf "$ZSHRC_APPEND"
105+
printf "\nsource \$ZSH/oh-my-zsh.sh"
106106
}
107107

108108
powerline10k_config() {
@@ -136,6 +136,16 @@ for plugin in $PLUGINS; do
136136
plugin_list="${plugin_list}$plugin_name "
137137
done
138138

139+
# Handle themes
140+
if [ "`echo $THEME | grep -E '^http.*'`" != "" ]; then
141+
theme_repo=`basename $THEME`
142+
THEME_DIR="$HOME/.oh-my-zsh/custom/themes/$theme_repo"
143+
git clone $THEME $THEME_DIR
144+
theme_name=`cd $THEME_DIR; ls *.zsh-theme | head -1`
145+
theme_name="${theme_name%.zsh-theme}"
146+
THEME="$theme_repo/$theme_name"
147+
fi
148+
139149
# Generate .zshrc
140150
zshrc_template "$HOME" "$THEME" "$plugin_list" > $HOME/.zshrc
141151

0 commit comments

Comments
 (0)