Skip to content

Commit

Permalink
Add OS-specific VSCodium extension installation
Browse files Browse the repository at this point in the history
ce224ae

- Improve formatting of printed comments
- Add `code`/`codium` command to PATH for macOS
- Add VSCodium as default distro: `CODE_DISTRO=${CODE_DISTRO:-"codium"}`
- Add error message if using Codespaces: Codespaces seems to have a
  limited version of the VSCode CLI that can't install extensions.

https://code.visualstudio.com/docs/setup/mac
microsoft/vscode#42051
https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces
  • Loading branch information
br3ndonland committed Oct 11, 2020
1 parent 45dc6ec commit 28f19a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
22 changes: 10 additions & 12 deletions script/codium_extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ install_codium_extensions() {
printf "Error: %s command not in PATH.\n" "$EDITOR" >&2
return 1
fi
printf "Installing extensions for %s\n" "$EDITOR"
printf "\nInstalling extensions for %s\n\n" "$EDITOR"
if [ "$EDITOR" = "code" ] || [ "$EDITOR" = "code-insiders" ]; then
cat ~/.dotfiles/codium/extensions/marketplace-open-vsx.txt \
~/.dotfiles/codium/extensions/marketplace-proprietary.txt \
Expand All @@ -27,14 +27,15 @@ install_codium_extensions() {
fi
done <$EXTENSIONS
}

if [ -z "$1" ]; then
printf "Error: No editor was given for the codium_extensions.sh script.\n"
printf "Please specify ≥1 editor [code, code-insiders, codium].\n"
printf "\nError: No editor was given for the codium_extensions.sh script.\n"
printf "Please specify ≥1 editor: code code-insiders codium\n"
exit 1
fi

for i in "$@"; do
EDITOR=$i
# Add editor command to PATH
case $i in
code)
APP="Visual\ Studio\ Code"
Expand All @@ -46,15 +47,12 @@ for i in "$@"; do
APP="VSCodium"
;;
esac
# TODO: Figure out how to use CLI without restarting terminal to install
# extensions via Strap. Currently, a terminal restart is needed before the CLI
# can be used. https://code.visualstudio.com/docs/setup/mac
# export PATH="$PATH:/Applications/$APP.app/Contents/Resources/app/bin"
printf "%s\n" $APP
# Install extensions
if [ "$(uname -s)" = "Darwin" ]; then
export PATH="/Applications/$APP.app/Contents/Resources/app/bin:$PATH"
fi
if install_codium_extensions; then
printf "install_codium_extensions() successful for %s.\n" "$i"
printf "\nExtensions successfully installed for %s.\n" "$i"
else
printf "Error: install_codium_extensions() unsuccessful for %s.\n" "$i"
printf "\nError: extensions not successfully installed for %s.\n" "$i"
fi
done
10 changes: 7 additions & 3 deletions script/strap-after-setup
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ echo "-> Running scripts from script/strap-after-setup"
~/.dotfiles/script/npm_globals.sh
[ "$(uname -s)" = "Darwin" ] && ~/.dotfiles/script/macos.sh

echo "-> Must install VSCodium CLI before running codium_extensions.sh."
echo "Open the app, then in the command palette, type 'shell command'."
# ~/.dotfiles/script/codium_extensions.sh codium code-insiders
echo "-> Installing VSCode extensions"
CODE_DISTRO=${CODE_DISTRO:-"codium"}
if [ "$(whoami)" = "codespace" ]; then
echo "Error: Codespaces VSCode CLI can't install extensions."
else
~/.dotfiles/script/codium_extensions.sh "$CODE_DISTRO"
fi

# Install Poetry: https://python-poetry.org/docs/
echo "-> Installing Poetry for Python packaging and dependency management"
Expand Down

0 comments on commit 28f19a6

Please sign in to comment.