A comprehensive, idempotent bash script designed to set up a complete development environment on macOS for TypeScript microservices development.
This script automates the installation and configuration of essential development tools, IDEs, databases, containerization tools, and terminal enhancements for modern web development. It's specifically tailored for developers working with:
- TypeScript/JavaScript microservices
- Node.js applications
- Docker containerization
- Database development (PostgreSQL, MongoDB, MySQL)
- Modern terminal workflows
- macOS (any recent version)
- Internet connection for downloading packages
- Administrator privileges (for installing system packages)
- Fresh macOS installation or willingness to install/update existing tools
# Clone or download the script
curl -O https://raw.githubusercontent.com/your-repo/setup-mac4dev.sh
# Make it executable
chmod +x setup-mac4dev.sh
# Run the script
./setup-mac4dev.sh# Run directly without downloading
bash <(curl -fsSL https://raw.githubusercontent.com/your-repo/setup-mac4dev.sh)- Idempotent: Safe to run multiple times
- Backup creation: Existing configurations are backed up before modification
- Error handling: Script exits on errors with clear messages
- OS validation: Only runs on macOS
- Homebrew - macOS package manager
- NVM - Node Version Manager for Node.js version control
- Git - Version control
- Node.js LTS - JavaScript runtime
- pnpm & yarn - Alternative package managers
- Python 3.11 - For Neovim and language servers
- Visual Studio Code - Primary IDE
- Cursor - AI-powered IDE
- Neovim + AstroNvim - Terminal-based IDE with modern features
- OrbStack - Lightweight Docker Desktop alternative
- Docker CLI tools - docker, docker-compose, docker-buildx
- TablePlus - Universal database client
- DBeaver Community - Free database client
- MongoDB Compass - Official MongoDB GUI
- CLI tools: pgcli, mycli, mongosh
- Brave Browser - Privacy-focused browser
- Google Chrome - Standard browser
- Firefox - Alternative browser
- Slack - Team communication
- Zoom - Video conferencing
- iTerm2 - Enhanced terminal
- Zsh with plugins - Modern shell with autosuggestions, syntax highlighting
- Starship - Cross-shell prompt
- Nerd Fonts - Programming fonts with icons
- API Testing: Postman, Insomnia
- Version Control GUI: SourceTree
- Modern CLI tools: bat, ripgrep, fd, fzf, htop
- Kubernetes tools: kubectl, helm, kubectx
- Cloud CLIs: AWS CLI, Azure CLI
The script installs 20+ essential extensions including:
- TypeScript/JavaScript support
- ESLint, Prettier
- Git integration (GitLens)
- Docker support
- Database tools
- Popular themes (Material, Dracula, GitHub, etc.)
- Zsh with modern plugins (autosuggestions, syntax highlighting, completions)
- Starship prompt with git status, Node.js version, Docker context
- Development aliases for common commands
- NVM integration for Node.js version management
- AstroNvim distribution with TypeScript-optimized configuration
- Language servers for TypeScript, ESLint, HTML, CSS, JSON, YAML
- Tree-sitter for enhanced syntax highlighting
- LSP integration with auto-formatting on save
- Prompts for username and email if not configured
- Sets VS Code as default editor
- Configures main as default branch
β οΈ Important Warnings:
- Starship Configuration: The script's Starship configuration may fail in some environments. If your prompt doesn't display correctly, use the manual setup commands below.
- AstroNvim Plugins: Some AstroNvim plugins may encounter installation issues, especially on first launch. This is normal and can be resolved with the troubleshooting steps below.
# If Homebrew installation fails, try:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"- Cause: VS Code CLI not available immediately after installation
- Solution: Run the script again after opening VS Code once, or install manually
# Add to ~/.zshrc if missing:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"- Issue: OrbStack needs manual setup after installation
- Solution: Launch OrbStack from Applications folder to complete Docker setup
# If you get permission errors:
sudo chown -R $(whoami) /usr/local/share/zsh- Issue: Starship prompt may not display correctly due to configuration issues
- Solution: If automatic configuration fails, manually configure Starship:
# Add to ~/.zshrc eval "$(starship init zsh)" # Or reset to default configuration starship preset default > ~/.config/starship.toml
- Reference: Starship Installation Guide
- Issue: Some plugins may fail to install or function incorrectly
- Common Problems:
- Missing dependencies (e.g.,
ripgrepfor search functionality) - Language servers not installing properly
- Tree-sitter parsers failing to load
- Missing dependencies (e.g.,
- Solutions:
# Install missing dependencies brew install ripgrep lazygit gdu bottom tree-sitter # In Neovim, check health and install missing components :checkhealth :Lazy sync :TSInstall <language> # e.g., :TSInstall typescript
- Reference: AstroNvim FAQ and Getting Started Guide
- Expected: First launch takes 5-10 minutes to install plugins
- Solution: Be patient, or run
:Lazy syncin Neovim
- Slow downloads: Some packages are large (VS Code, browsers)
- Timeout errors: Retry the script or install packages individually
- Requirement: ~10-15GB free space
- Large packages: VS Code, browsers, Docker images
After successful completion, you'll have:
- Modern terminal with enhanced productivity features
- Multiple code editors configured for TypeScript development
- Containerization tools ready for microservices
- Database clients for all major databases
- Git configured with your credentials
- Development aliases for common tasks
- Node.js version management via NVM
- Auto-formatting and linting in editors
- Consistent theming across tools
- Language servers for intelligent code completion
- Modern CLI tools replacing legacy ones
- Cloud and Kubernetes tools for deployment
- Restart Terminal:
source ~/.zshrcor open new terminal - Configure iTerm2: Set font to 'FiraCode Nerd Font Mono'
- Launch OrbStack: Complete Docker setup from Applications
- Verify Extensions: Open VS Code/Cursor to check extensions
- Test Neovim: Run
nvim- plugins will auto-install - Install Node Versions: Use
nvm install <version>as needed
# Development shortcuts
nvim # Open Neovim with AstroNvim
code . # Open current directory in VS Code
cursor . # Open current directory in Cursor
dc up # Docker Compose up
pgcli # Enhanced PostgreSQL CLI
lazygit # Git TUI
# Node.js management
nvm use 18 # Switch to Node 18
nvm install 20 # Install Node 20
npx typescript # Run TypeScript without global install
# Modern CLI tools
bat file.txt # Better cat
rg "pattern" # Better grep
fd "name" # Better find- Leader key:
<Space> - Find files:
<Space>ff - Find word:
<Space>fw - File explorer:
<Space>e - LazyGit:
<Space>gg - Documentation: https://docs.astronvim.com
If you encounter issues:
- Check the troubleshooting section above
- Ensure you have sufficient disk space and internet connection
- Try running the script again (it's idempotent)
- Check the script logs for specific error messages
This script is provided as-is for educational and development purposes. Use at your own discretion and always review scripts before execution.
Happy coding! π