Professional bash development environment with VS Code devcontainer, BATS testing, debugging, and AI integration
A comprehensive VS Code development container template designed for professional bash script development. This template provides a complete development environment with modern tooling, testing frameworks, debugging capabilities, and AI-enhanced workflows.
- π³ Development Container: Ubuntu-based devcontainer with Zsh shell and custom setup tools
- π§ͺ Testing Framework: BATS-Core with assertion and support helper libraries
- π Debugging Support: BashDB integration with VS Code debugging interface
- β Code Quality: ShellCheck linting and shfmt formatting with real-time feedback
- π€ AI Integration: GitHub Copilot with custom instructions and MCP servers
- π Project Structure: Organized file layout for scalable bash projects
- β‘ Developer Experience: Custom aliases, themes, and VS Code task integration
- π§ Setup Automation: Custom devcontainer tools for zsh plugins and configuration management
/
βββ src/ # Source bash scripts
βββ test/ # BATS test files and framework
β βββ *.bats # Test implementations
β βββ bats/ # BATS core (submodule)
β βββ test_helper/ # Helper libraries (submodules)
βββ .devcontainer/ # Container configuration
β βββ devcontainer.json # Main container config
β βββ setup/ # Custom setup tools
β β βββ install-zsh-plugins/ # Zinit plugin installer
β β βββ install-custom-config/ # Oh-my-zsh config loader
β β βββ switch-apt-mirror/ # APT mirror switcher
β βββ etc/ # Environment configurations
βββ .vscode/ # IDE configuration
β βββ tasks.json # Build and test tasks
β βββ launch.json # Debug configurations
β βββ settings.json # Editor settings
βββ .github/ # AI instructions and metadata
βββ docs/ # Documentation and guidelines- VS Code with Dev Containers extension
- Docker installed and running
-
Use this template to create a new repository or clone directly:
git clone https://github.com/thecodecrate/devcontainer-bash.git my-bash-project cd my-bash-project -
Open in VS Code:
code . -
Reopen in Container when prompted, or use Command Palette:
Ctrl+Shift+Pβ "Dev Containers: Reopen in Container"
-
Start developing! The environment includes:
- Example script:
src/example.sh - Example test:
test/example.bats - Pre-configured tasks and debugging
- Example script:
Run the example test to verify everything works:
# Using VS Code task (Ctrl+Shift+P β "Tasks: Run Task" β "Test (Bats)")
./test/bats/bin/bats test/
# Or run specific test file
./test/bats/bin/bats test/example.batsDebug the example script:
- Open
src/example.sh - Set a breakpoint (click left margin)
- Press
F5or use "Run and Debug" panel
- Create scripts in
src/directory following the shell style guide - Add tests in
test/directory using BATS syntax - Use VS Code features:
- IntelliSense for bash commands and variables
- Real-time ShellCheck linting
- Format on save with shfmt
- Run all tests: Use "Test (Bats)" task or
./test/bats/bin/bats test/ - Run specific test:
./test/bats/bin/bats test/my_test.bats - Watch mode: Not built-in, but easy to add with file watchers
- Interactive debugging: Set breakpoints and press
F5 - Variable inspection: Use Debug Console and Watch panels
- Step execution: Step into, over, and out of functions
- Linting: ShellCheck runs automatically, see Problems panel
- Formatting: Format on save enabled, or use
Shift+Alt+F - Custom rules: Configure in
.vscode/settings.jsonor.shellcheckrc
The template includes a custom tool for installing zsh plugins via zinit:
{
"containerEnv": {
"WITH_ZSH_PLUGINS": "zsh-users/zsh-autosuggestions zsh-users/zsh-syntax-highlighting"
}
}Use the install-custom-config tool to automatically load custom scripts:
./.devcontainer/setup/install-custom-config/setup.bash --custom-dir /path/to/custom/scriptsFor faster package installation in certain regions:
./.devcontainer/setup/switch-apt-mirror/setup.bash mirrors.kernel.orgAdd extensions to .devcontainer/devcontainer.json:
{
"customizations": {
"vscode": {
"extensions": [
"your.extension.id"
]
}
}
}| Task | Description | Shortcut |
|---|---|---|
| Test (Bats) | Run all BATS tests | Ctrl+Shift+P β Tasks |
| Lint Scripts | Run ShellCheck on all scripts | Available in task menu |
| Format Scripts | Format all scripts with shfmt | Available in task menu |
This template includes comprehensive AI assistance:
- Custom instructions for bash development in
.github/copilot-instructions.md - Context-aware suggestions for shell scripting patterns
- Integrated with VS Code for seamless code completion
Pre-configured MCP servers provide enhanced AI capabilities:
- Brave Search: Web search for documentation and examples
- Memory: Persistent project knowledge and context
- Git: Repository operations and version control assistance
- Filesystem: Secure file operations with access controls
- Fetch: Web content retrieval and markdown conversion
- Shell Style Guide: Coding standards and best practices
- Commit Style Guide: Git commit message conventions
- SPECIFICATION.md: Complete technical specification
- Tool Specifications: Detailed docs for each custom devcontainer tool
- install-zsh-plugins: Automated zinit plugin installation
- install-custom-config: Oh-my-zsh configuration loader
- switch-apt-mirror: APT repository mirror management
- BATS-Core: Bash testing framework with helpers
- BashDB: Interactive bash debugger
- ShellCheck: Static analysis and linting
- shfmt: Shell script formatting
- Zinit: Fast zsh plugin manager
MIT License - Use this template freely for your projects.
Status: π§ In Development | Target: Professional Bash Development Environment | Maintainer: @thecodecrate