Technical Article

Configuration Folder Management: A Complete Guide to Setting Up Development Tools

Learn how to set up and manage configuration folders for PowerShell, Wezterm, and other development tools with version control

Configuration Folder Management: A Complete Guide to Setting Up Development Tools

Managing configuration files and folders is essential for maintaining a consistent development environment across different machines and ensuring your settings are backed up and version controlled. This guide covers how to set up configuration folders for various development tools and applications.

Understanding Configuration Management

Why Configuration Management Matters

Proper configuration management provides several benefits:

  • Consistency: Same settings across all your machines
  • Backup: Your configurations are safely stored and version controlled
  • Portability: Easy to set up new development environments
  • Collaboration: Share configurations with team members
  • Disaster Recovery: Quickly restore settings after system issues

Common Configuration Patterns

Most applications follow these configuration patterns:

  1. User-specific: Settings stored in user profile directories
  2. Cross-platform: Consistent paths across Windows, Linux, and macOS
  3. Version controlled: Git repositories for configuration management
  4. Modular: Separate repositories for different tools

PowerShell Configuration

PowerShell Profile Locations

PowerShell uses different profile locations depending on the platform and scope:

Windows PowerShell Profile Paths

# Current User, Current Host
$PROFILE.CurrentUserCurrentHost
# Result: C:\Users\[USERNAME]\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

# Current User, All Hosts
$PROFILE.CurrentUserAllHosts
# Result: C:\Users\[USERNAME]\Documents\PowerShell\profile.ps1

# All Users, Current Host
$PROFILE.AllUsersCurrentHost
# Result: C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1

# All Users, All Hosts
$PROFILE.AllUsersAllHosts
# Result: C:\Program Files\PowerShell\7\profile.ps1

Cross-Platform PowerShell Core Paths

# Windows
$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

# Linux
~/.config/powershell/Microsoft.PowerShell_profile.ps1

# macOS
~/.config/powershell/Microsoft.PowerShell_profile.ps1

Setting Up PowerShell Configuration

Step 1: Create Configuration Directory

# Create PowerShell configuration directory
New-Item -ItemType Directory -Path "$HOME\Documents\PowerShell" -Force

Step 2: Clone Configuration Repository

# Clone your PowerShell configuration repository
git clone https://github.com/dantesg/powershell "$HOME\Documents\PowerShell\config"

# Create symbolic link to profile
New-Item -ItemType SymbolicLink -Path $PROFILE.CurrentUserCurrentHost -Target "$HOME\Documents\PowerShell\config\profile.ps1" -Force

Step 3: Verify Configuration

# Test profile loading
. $PROFILE.CurrentUserCurrentHost

# Check if profile exists
Test-Path $PROFILE.CurrentUserCurrentHost

PowerShell Profile Structure

A well-organized PowerShell profile might look like this:

# PowerShell Profile Structure
$HOME\Documents\PowerShell\config\
├── profile.ps1              # Main profile file
├── modules\                 # Custom modules
│   ├── Git.psm1
│   └── Utils.psm1
├── functions\               # Custom functions
│   ├── Navigation.ps1
│   └── Development.ps1
├── aliases\                 # Custom aliases
│   └── Aliases.ps1
└── themes\                  # Custom themes
    └── CustomTheme.ps1

Wezterm Configuration

Wezterm Configuration Locations

Wezterm uses consistent configuration paths across platforms:

Windows Configuration Path

$HOME\.config\wezterm

Linux Configuration Path

~/.config/wezterm

macOS Configuration Path

~/.config/wezterm

Setting Up Wezterm Configuration

Step 1: Create Configuration Directory

# Windows
New-Item -ItemType Directory -Path "$HOME\.config\wezterm" -Force

# Linux/macOS
mkdir -p ~/.config/wezterm

Step 2: Clone Configuration Repository

# Clone Wezterm configuration
git clone https://github.com/dantesg/wezterm "$HOME\.config\wezterm\config"

# Create symbolic link to main config
New-Item -ItemType SymbolicLink -Path "$HOME\.config\wezterm\wezterm.lua" -Target "$HOME\.config\wezterm\config\wezterm.lua" -Force

Step 3: Verify Configuration

# Test Wezterm configuration
wezterm --config-file "$HOME\.config\wezterm\wezterm.lua" --config check

Wezterm Configuration Structure

-- Wezterm Configuration Structure
$HOME\.config\wezterm\
├── wezterm.lua              # Main configuration file
├── config\
│   ├── colors.lua           # Color schemes
│   ├── keys.lua             # Key bindings
│   ├── fonts.lua            # Font configurations
│   └── windows.lua          # Window settings
└── assets\                  # Custom assets
    ├── icons\
    └── backgrounds\

Additional Development Tools

Git Configuration

Global Git Configuration

# Set up Git configuration
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global core.editor "code --wait"
git config --global init.defaultBranch main

Git Configuration Files

# Global Git config location
~/.gitconfig

# Repository-specific config
.git/config

Neovim Configuration

Neovim Configuration Paths

# Windows
$env:LOCALAPPDATA\nvim

# Linux/macOS
~/.config/nvim

Setting Up Neovim Configuration

# Create Neovim configuration directory
mkdir $env:LOCALAPPDATA\nvim

# Clone configuration repository
git clone https://github.com/dantesg/dotfiles.git
cd dotfiles

# Copy configuration files
xcopy .\config\init.lua $env:LOCALAPPDATA\nvim\
xcopy /s/e .\config\after\ $env:LOCALAPPDATA\nvim\after\
xcopy /s/e .\config\lua\ $env:LOCALAPPDATA\nvim\lua\

VS Code Configuration

VS Code Settings Locations

# Windows
$env:APPDATA\Code\User\settings.json

# Linux
~/.config/Code/User/settings.json

# macOS
~/Library/Application Support/Code/User/settings.json

Setting Up VS Code Configuration

# Create VS Code configuration directory
New-Item -ItemType Directory -Path "$env:APPDATA\Code\User" -Force

# Clone VS Code settings repository
git clone https://github.com/dantesg/vscode-settings "$env:APPDATA\Code\User\config"

# Create symbolic link
New-Item -ItemType SymbolicLink -Path "$env:APPDATA\Code\User\settings.json" -Target "$env:APPDATA\Code\User\config\settings.json" -Force

Configuration Management Best Practices

1. Repository Organization

Organize your configuration repositories logically:

dotfiles/
├── powershell/
│   ├── profile.ps1
│   └── modules/
├── wezterm/
│   └── wezterm.lua
├── nvim/
│   ├── init.lua
│   └── lua/
├── vscode/
│   └── settings.json
└── scripts/
    ├── install.ps1
    └── setup.sh

2. Installation Scripts

Create automated installation scripts:

PowerShell Installation Script

# install-config.ps1
param(
    [string]$ConfigRepo = "https://github.com/dantesg/dotfiles",
    [string]$InstallPath = "$HOME\dotfiles"
)

Write-Host "Installing development configuration..." -ForegroundColor Green

# Clone configuration repository
if (Test-Path $InstallPath) {
    Write-Host "Configuration already exists. Updating..." -ForegroundColor Yellow
    Set-Location $InstallPath
    git pull
} else {
    Write-Host "Cloning configuration repository..." -ForegroundColor Yellow
    git clone $ConfigRepo $InstallPath
}

# Install PowerShell configuration
Write-Host "Installing PowerShell configuration..." -ForegroundColor Yellow
$powershellConfig = "$InstallPath\powershell"
if (Test-Path $powershellConfig) {
    New-Item -ItemType SymbolicLink -Path $PROFILE.CurrentUserCurrentHost -Target "$powershellConfig\profile.ps1" -Force
}

# Install Wezterm configuration
Write-Host "Installing Wezterm configuration..." -ForegroundColor Yellow
$weztermConfig = "$InstallPath\wezterm"
if (Test-Path $weztermConfig) {
    New-Item -ItemType Directory -Path "$HOME\.config\wezterm" -Force
    New-Item -ItemType SymbolicLink -Path "$HOME\.config\wezterm\wezterm.lua" -Target "$weztermConfig\wezterm.lua" -Force
}

Write-Host "Configuration installation complete!" -ForegroundColor Green

Bash Installation Script

#!/bin/bash
# install-config.sh

CONFIG_REPO="https://github.com/dantesg/dotfiles"
INSTALL_PATH="$HOME/dotfiles"

echo "Installing development configuration..."

# Clone configuration repository
if [ -d "$INSTALL_PATH" ]; then
    echo "Configuration already exists. Updating..."
    cd "$INSTALL_PATH"
    git pull
else
    echo "Cloning configuration repository..."
    git clone "$CONFIG_REPO" "$INSTALL_PATH"
fi

# Install Wezterm configuration
echo "Installing Wezterm configuration..."
WEZTERM_CONFIG="$INSTALL_PATH/wezterm"
if [ -d "$WEZTERM_CONFIG" ]; then
    mkdir -p "$HOME/.config/wezterm"
    ln -sf "$WEZTERM_CONFIG/wezterm.lua" "$HOME/.config/wezterm/wezterm.lua"
fi

echo "Configuration installation complete!"

3. Environment Detection

Create scripts that detect the environment and install appropriate configurations:

# detect-environment.ps1
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$isWindows = $os.Caption -like "*Windows*"
$isLinux = $os.Caption -like "*Linux*"
$isMacOS = $os.Caption -like "*macOS*"

Write-Host "Detected OS: $($os.Caption)" -ForegroundColor Green

if ($isWindows) {
    Write-Host "Installing Windows-specific configurations..." -ForegroundColor Yellow
    # Windows-specific installation steps
} elseif ($isLinux) {
    Write-Host "Installing Linux-specific configurations..." -ForegroundColor Yellow
    # Linux-specific installation steps
} elseif ($isMacOS) {
    Write-Host "Installing macOS-specific configurations..." -ForegroundColor Yellow
    # macOS-specific installation steps
}

4. Backup and Sync

Implement backup and synchronization strategies:

# backup-config.ps1
$backupPath = "$HOME\config-backup\$(Get-Date -Format 'yyyy-MM-dd-HHmmss')"
New-Item -ItemType Directory -Path $backupPath -Force

# Backup PowerShell configuration
if (Test-Path $PROFILE.CurrentUserCurrentHost) {
    Copy-Item $PROFILE.CurrentUserCurrentHost "$backupPath\powershell-profile.ps1"
}

# Backup Wezterm configuration
if (Test-Path "$HOME\.config\wezterm\wezterm.lua") {
    Copy-Item "$HOME\.config\wezterm\wezterm.lua" "$backupPath\wezterm.lua"
}

Write-Host "Configuration backed up to: $backupPath" -ForegroundColor Green

Troubleshooting Common Issues

Issue 1: Profile Not Loading

Symptoms: PowerShell profile doesn’t load on startup Solutions:

  • Check execution policy: Get-ExecutionPolicy
  • Set execution policy: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  • Verify profile path: $PROFILE.CurrentUserCurrentHost
  • Test profile manually: . $PROFILE.CurrentUserCurrentHost

Symptoms: Configuration changes not reflected Solutions:

  • Verify symbolic link: Get-Item $PROFILE.CurrentUserCurrentHost | Select-Object LinkType
  • Recreate symbolic link: Remove and recreate the link
  • Check permissions: Ensure you have write access to target directories

Issue 3: Cross-Platform Compatibility

Symptoms: Configuration doesn’t work on different platforms Solutions:

  • Use platform detection in scripts
  • Create platform-specific configuration files
  • Test configurations on all target platforms
  • Use relative paths when possible

Security Considerations

1. Sensitive Information

  • Never commit secrets: Use environment variables or secure vaults
  • Encrypt sensitive configs: Use tools like git-crypt for sensitive files
  • Use .gitignore: Exclude files containing personal information

2. Access Control

  • Repository permissions: Control who can access your configuration repositories
  • Local file permissions: Set appropriate file permissions on configuration files
  • Audit configurations: Regularly review what’s being stored in your configurations

Conclusion

Proper configuration management is essential for maintaining a productive development environment. By following the patterns and best practices outlined in this guide, you can create a robust, portable, and maintainable configuration setup.

Key Takeaways

  1. Centralized Management: Use version-controlled repositories for configurations
  2. Cross-Platform Compatibility: Design configurations that work across different operating systems
  3. Automation: Create scripts to automate configuration installation and updates
  4. Security: Protect sensitive information and use appropriate access controls
  5. Documentation: Document your configuration setup for future reference

Quick Reference

# PowerShell profile location
$PROFILE.CurrentUserCurrentHost

# Wezterm config location (Windows)
$HOME\.config\wezterm

# Neovim config location (Windows)
$env:LOCALAPPDATA\nvim

# Create symbolic link
New-Item -ItemType SymbolicLink -Path $target -Target $source -Force

With proper configuration management, you can ensure your development environment is consistent, backed up, and easily reproducible across different machines and platforms.