Skip to content

Commit ae3f877

Browse files
committed
Mojo: Fix onCreateCommand
1 parent 0836012 commit ae3f877

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

.devcontainer/scripts/usr/local/bin/onCreateCommand.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,31 @@ else
5252
fi
5353
fi
5454

55-
if ! grep -q "user's private bin" "$HOME/.bashrc"; then
56-
# If existent, prepend the user's private bin to PATH
57-
cat "/var/tmp/snippets/rc.sh" >> "$HOME/.bashrc"
58-
fi
59-
if ! grep -q "user's private bin" "$HOME/.zshrc"; then
60-
if [ "$(command -v mojo)" ]; then
61-
# Append the magic bin dir to PATH
55+
if [ "$(command -v mojo)" ]; then
56+
# Append the user's modular bin dir to PATH
57+
if ! grep -q "user's modular bin dir" "$HOME/.bashrc"; then
58+
curl -ssL https://magic.modular.com | grep '^MODULAR_HOME\|^BIN_DIR' \
59+
> /tmp/magicenv
60+
sed -i 's/\$HOME/\\$HOME/g' /tmp/magicenv
61+
. /tmp/magicenv
62+
echo -e "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" >> "$HOME/.bashrc"
63+
rm /tmp/magicenv
64+
fi
65+
if ! grep -q "user's modular bin dir" "$HOME/.zshrc"; then
6266
curl -ssL https://magic.modular.com | grep '^MODULAR_HOME\|^BIN_DIR' \
6367
> /tmp/magicenv
6468
sed -i 's/\$HOME/\\$HOME/g' /tmp/magicenv
6569
. /tmp/magicenv
66-
echo -e "\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" >> "$HOME/.zshrc"
70+
echo -e "\n# Append the user's modular bin dir to PATH\nif [[ \"\$PATH\" != *\"${BIN_DIR}\"* ]] ; then\n PATH=\"\$PATH:${BIN_DIR}\"\nfi" >> "$HOME/.zshrc"
6771
rm /tmp/magicenv
6872
fi
69-
# If existent, prepend the user's private bin to PATH
73+
fi
74+
75+
# If existent, prepend the user's private bin to PATH
76+
if ! grep -q "user's private bin" "$HOME/.bashrc"; then
77+
cat "/var/tmp/snippets/rc.sh" >> "$HOME/.bashrc"
78+
fi
79+
if ! grep -q "user's private bin" "$HOME/.zshrc"; then
7080
cat "/var/tmp/snippets/rc.sh" >> "$HOME/.zshrc"
7181
fi
7282

0 commit comments

Comments
 (0)