Skip to content

Supercharge your Visual Studio Code to code faster, easier, and more enjoyably in any language (Python, Powershell, Shell, Markdown, YAML, TOML, and more) in this fully pre-configured, customized, optimized, and isolated dev environment. Say goodbye to other IDE's like Pycharm, Windows PowerShell ISE, etc.

Notifications You must be signed in to change notification settings

JesseWebDotCom/vscode-dev-container

Repository files navigation

vscode-dev-container

Supercharge your Visual Studio Code to code faster, easier, and more enjoyably in any language (Python, Powershell, Shell, Markdown, YAML, TOML, and more) in this fully pre-configured, customized, optimized, and isolated dev environment. Say goodbye to other IDE's like Pycharm, Windows PowerShell ISE, etc.

With the code from this repo, your Visual Studio Code will be fully configured and optimized with multi-language support and enhancements using a preconfigured dev container. No more wasting time finding and installing extensions, configuring settings, etc.

Additionally installed are a collection of custom tools designed to simplify and speed up development and administration (ex. creating projects from predefined templates).

Finally, all your project dependencies will live and run in a dev container, isolated from your host system (similar but more powerful than Python virtual environments); keeping your host system clean and allowing you to easily and quickly port your dev environment to another system when needed.

Installation, customization, and usage is a snap.

Highlights

While this container is packed with ton of great features, here are just some of the highlights.

LanguageHighlights
All
  • Easily configure container time zone, terminal themes, additional packages, etc.
  • Create projects from configurable templates
  • Standardize Run button across all executable file types
  • Terminal theming through oh-my-posh
  • Quick action helpers (ex. create project from template) available via VS Code Tasks or terminal
  • IDE enhancements like better fonts, icons for file/folder, task explorer, TODO tree, etc.
  • More...
Markdown
  • Auto-Preview
  • Formatting (markdownlint)
  • Linting (markdownlint)
  • More...
Python
  • Auto-REPL
  • Documenting (autoDocstring)
  • Execution (code runner)
  • Formatting (black, autopep8, yapf)
  • Intellisense (pylance, type hints)
  • Linting (mypy, bandit, flake8, pylint, pycodestyle)
  • Testing (pytest)
  • More...
PowerShell
  • Execution (code runner)
  • Formatting (powershell)
  • Intellisense (powershell)
  • Linting (psscriptanalyzer)
Shell
  • Debugging (bash debug)
  • Formatting (shell-formatter)
  • Intellisense (bash ide)
  • Linting (shell-check)
  • Testing (tbd)
  • More...
TOML
  • Formatting (prettier toml)
  • Linting (better toml)
  • More...
YAML
  • Formatting (red hat)
  • Linting (red hat)
  • More...
Other
  • Formatting (prettier)
  • More...

Check out the Extensions page for a full listing of every extension included.

Screenshots

Terminals

Bash Bash Terminal ZSH ZSH Terminal PWSH PWSH Terminal

Linting

Linting

Installation

Prerequisites

Install the following tools (links to the tool downloads and installation walkthroughs if you need them below):

Tool Walkthrough
Git Windows / Mac
VS Code Windows / Mac
Docker Desktop Windows / Mac
Remote-Containers VS Code Extension Windows / Mac

Setup

  1. Open Docker Desktop and configure its settings to start at login Docker - Start at Login
  2. Clone this repo
  3. Run the host setup script:
    • Macintosh: tools/host_setup_mac.sh
    • Windows: tools/host_setup_win.cmd
  4. [optional] Configure the customziation files as needed (they can be blank but must be present)
  5. Start VS Code, run the Remote-Containers: Open Folder in Container... command from the Command Palette (F1) or quick actions Status bar item, and select the cloned repo folder. The container will start building (ignore any popups, ex. Cannot activate..., Reload window...)
  6. After the container builds (i.e. commands in the terminal window stop), restart VS Code.

Updating

Simply download the latest files from this repo, add/overwite them in your project, and rebuild the container (i.e. open command pallette and run "Remote-Containers: Rebuild Container").


NOTE

Ensure you do not overwrite existing files that you may have altered (ex. .gitignore, templates, etc.)


Configuration

[optional] While this environment and settings work for me, they may not be ideal for everyone. For example, you may need to set a different container time zone, use a different terminal theme, or install some additional packages into the container. While you could directly modify the default install script and environment file that controls these things, those files would then be out of sync with this repo (making it difficult for you to use updated versions as I post them). Instead, create and use customization files.

Defaults

These files contain the core configurations for the container and should not be modified.

  • .devcontainer/build/setup_container.sh - installs default packages (ex. powershell) and configurations (ex. extension caching)
  • .devcontainer/build/variables.env - sets time zone, PowerShell version, etc.

Customizations

These files allow you to customize the container with customizations like setting your desired time zone, terminal theme, container & python package installs, etc. You may leave them blank if you do not have any customizations but they need to be present to prevent the container build from failing.

  • .devcontainer/customize/setup_container.sh - add custom commands needed for your project (ex. install packages). These commands will be run after .devcontainer/build/setup_container.sh is run.

    • TIP: Call tools/project_create.py (with the desired parameters) to auto create your project structure
    • TIP: For python projects, call to install your requirements and constraints (ex. pip3 install -r requirements.txt -c constraints.txt) }
  • .devcontainer/customize/variables.env - set your time zone, desired PowerShell version, etc. The variables here will be merged with and override variables found in the devcontainer.json.


NOTE

Whenever you add/edit customizations, you also need to rebuild the container (i.e. open command pallette and run "Remote-Containers: Rebuild Container").


HOWTO

Create a project from a template

When creating new projects, you typically end up manually creating the same folders (ex. src/proj/your_project) and files (ex. readme.md, requirements.txt, src/proj/your_project/init.py, etc.). You also have to manually add the same data to some of the project files (ex. project name at the top of the readme.md).

Instead, you can automatically create a new project with a template:

  1. Find or create your desired template in /templates (see included ones for examples)
  2. Run tools/project_create.py (with the desired parameters) OR run the VS Code task Projects: Create

Issues

  • If your terminal fonts look weird and or you see a popup stating The terminal only Supports monospace fonts, run the host setup script for your OS and restart VS Code.
  • Naming a source code subfolder "py" will break test discovery. This seems to be a known VS Code issue
  • "\r': command not found" - If you see this on a Windows system this likely means a *.sh file contains a Windows line feed. Update the file to change Windows line feeds to Unix line feeds.
  • Stop (1333 ms): Check Docker is running - Docker Desktop may not be running. Start it and see if the error persists.

About

Supercharge your Visual Studio Code to code faster, easier, and more enjoyably in any language (Python, Powershell, Shell, Markdown, YAML, TOML, and more) in this fully pre-configured, customized, optimized, and isolated dev environment. Say goodbye to other IDE's like Pycharm, Windows PowerShell ISE, etc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published