Giter VIP home page Giter VIP logo

Comments (3)

aaronlehmann avatar aaronlehmann commented on August 11, 2024 9

I've been using this snippet of code in the devcontainer startup script to install VS Code extensions specified in devcontainer.json. It's a pretty gross hack and you may well be able to come up with something better, but it might be useful as an example:

  if ! which code-server > /dev/null; then
    curl -fsSL https://code-server.dev/install.sh | sh | tee code-server-install.log
  fi
  CODE_CLI=code-server
  if code -v > /dev/null; then
    CODE_CLI=code
  fi
  mkdir -p ~/.vscode-server/extensions

  set +e
  extensions=( $(sed 's/\/\/.*$//g' */.devcontainer/devcontainer.json | jq -r -M '[.customizations.vscode.extensions[]?, .extensions[]?] | .[]' ) )
  if [ "$${extensions[0]}" != "" ] && [ "$${extensions[0]}" != "null" ]; then
    for extension in "$${extensions[@]}"; do
      $CODE_CLI --extensions-dir ~/.vscode-server/extensions --install-extension "$extension"
    done
  fi

from envbuilder.

kylecarbs avatar kylecarbs commented on August 11, 2024

@geiseri if you have the VS Code Dev Containers extension do the customizations automatically install?

from envbuilder.

michaelbrewer avatar michaelbrewer commented on August 11, 2024

Ended up doing something very similar, would be nice to have this built in

    curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.22.0

    CODE_CLI=/tmp/code-server/bin/code-server
    DEVCONTAINER_JSON=".devcontainer/devcontainer.json"
    if [[ -f "$DEVCONTAINER_JSON" ]]; then
        EXTENSIONS=$(sed '/^ *\/\//d' "$DEVCONTAINER_JSON" | jq -r '.customizations.vscode.extensions[]?')
        if [[ -n "$EXTENSIONS" ]]; then
            # Loop over each extension and install it
            for EXTENSION in $EXTENSIONS; do
                $CODE_CLI --install-extension $EXTENSION
            done
        fi
    fi

    $CODE_CLI --auth none --port 13337 >/tmp/code-server.log 2>&1 &

from envbuilder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.