surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| @@ -1,4 +1,4 @@ | ||
| 1 | -<# | |
| 1 | +<# | |
| 2 | 2 | .SYNOPSIS |
| 3 | 3 | Automates the setup and connection to a DevContainer environment using either Docker or Podman on Windows. |
| 4 | 4 | |
| @@ -25,6 +25,7 @@ | ||
| 25 | 25 | └── Script/ |
| 26 | 26 | └── run_devcontainer_claude_code.ps1 |
| 27 | 27 | #> |
| 28 | + | |
| 28 | 29 | [CmdletBinding()] |
| 29 | 30 | param( |
| 30 | 31 | [Parameter(Mandatory=$true)] |
| @@ -43,7 +44,7 @@ | ||
| 43 | 44 | # --- Step 1a: Initialize Podman machine --- |
| 44 | 45 | Write-Host "Initializing Podman machine 'claudeVM'..." |
| 45 | 46 | try { |
| 46 | - podman machine init claudeVM | |
| 47 | + & podman machine init claudeVM | |
| 47 | 48 | Write-Host "Podman machine 'claudeVM' initialized or already exists." |
| 48 | 49 | } catch { |
| 49 | 50 | Write-Error "Failed to initialize Podman machine: $($_.Exception.Message)" |
| @@ -53,7 +54,7 @@ | ||
| 53 | 54 | # --- Step 1b: Start Podman machine --- |
| 54 | 55 | Write-Host "Starting Podman machine 'claudeVM'..." |
| 55 | 56 | try { |
| 56 | - podman machine start claudeVM -q | |
| 57 | + & podman machine start claudeVM -q | |
| 57 | 58 | Write-Host "Podman machine started or already running." |
| 58 | 59 | } catch { |
| 59 | 60 | Write-Error "Failed to start Podman machine: $($_.Exception.Message)" |
| @@ -63,7 +64,7 @@ | ||
| 63 | 64 | # --- Step 2: Set default connection --- |
| 64 | 65 | Write-Host "Setting default Podman connection to 'claudeVM'..." |
| 65 | 66 | try { |
| 66 | - podman system connection default claudeVM | |
| 67 | + & podman system connection default claudeVM | |
| 67 | 68 | Write-Host "Default connection set." |
| 68 | 69 | } catch { |
| 69 | 70 | Write-Warning "Failed to set default Podman connection (may be already set or machine issue): $($_.Exception.Message)" |
| @@ -87,11 +88,11 @@ | ||
| 87 | 88 | # --- Step 3: Bring up DevContainer --- |
| 88 | 89 | Write-Host "Bringing up DevContainer in the current folder..." |
| 89 | 90 | try { |
| 90 | - $devcontainerUpCommand = "devcontainer up --workspace-folder ." | |
| 91 | + $arguments = @('up', '--workspace-folder', '.') | |
| 91 | 92 | if ($Backend -eq 'podman') { |
| 92 | - $devcontainerUpCommand += " --docker-path podman" | |
| 93 | + $arguments += '--docker-path', 'podman' | |
| 93 | 94 | } |
| 94 | - Invoke-Expression $devcontainerUpCommand | |
| 95 | + & devcontainer @arguments | |
| 95 | 96 | Write-Host "DevContainer startup process completed." |
| 96 | 97 | } catch { |
| 97 | 98 | Write-Error "Failed to bring up DevContainer: $($_.Exception.Message)" |
| @@ -102,12 +103,11 @@ | ||
| 102 | 103 | Write-Host "Finding the DevContainer ID..." |
| 103 | 104 | $currentFolder = (Get-Location).Path |
| 104 | 105 | |
| 105 | -$psCommand = "$($Backend) ps --filter ""label=devcontainer.local_folder=$currentFolder"" --format ""{{.ID}}""" | |
| 106 | - | |
| 107 | 106 | try { |
| 108 | - $containerId = $(Invoke-Expression $psCommand).Trim() | |
| 107 | + $containerId = (& $Backend ps --filter "label=devcontainer.local_folder=$currentFolder" --format '{{.ID}}').Trim() | |
| 109 | 108 | } catch { |
| 110 | - Write-Error "Failed to get container ID (Command: $psCommand): $($_.Exception.Message)" | |
| 109 | + $displayCommand = "$Backend ps --filter `"label=devcontainer.local_folder=$currentFolder`" --format '{{.ID}}'" | |
| 110 | + Write-Error "Failed to get container ID (Command: $displayCommand): $($_.Exception.Message)" | |
| 111 | 111 | exit 1 |
| 112 | 112 | } |
| 113 | 113 | |
| @@ -121,13 +121,11 @@ | ||
| 121 | 121 | # --- Step 5 & 6: Execute command and enter interactive shell inside container --- |
| 122 | 122 | Write-Host "Executing 'claude' command and then starting zsh session inside container $($containerId)..." |
| 123 | 123 | try { |
| 124 | - $execCommand = "$($Backend) exec -it $containerId zsh -c 'claude; exec zsh'" | |
| 125 | - Invoke-Expression $execCommand | |
| 126 | - | |
| 124 | + & $Backend exec -it $containerId zsh -c 'claude; exec zsh' | |
| 127 | 125 | Write-Host "Interactive session ended." |
| 128 | - | |
| 129 | 126 | } catch { |
| 130 | - Write-Error "Failed to execute command inside container (Command: $execCommand): $($_.Exception.Message)" | |
| 127 | + $displayCommand = "$Backend exec -it $containerId zsh -c 'claude; exec zsh'" | |
| 128 | + Write-Error "Failed to execute command inside container (Command: $displayCommand): $($_.Exception.Message)" | |
| 131 | 129 | exit 1 |
| 132 | 130 | } |
| 133 | 131 |