Repository navigation
Expand file tree
/
Copy pathshell-wrapper.ps1
More file actions
77 lines (65 loc) · 2.56 KB
/
Copy pathshell-wrapper.ps1
File metadata and controls
77 lines (65 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Claude Config Changer PowerShell Wrapper
# This file should be sourced in your PowerShell profile
function ccc {
param(
[Parameter(ValueFromRemainingArguments=$true)]
[string[]]$Arguments
)
# Save current environment
$OLD_ANTHROPIC_BASE_URL = $env:ANTHROPIC_BASE_URL
$OLD_ANTHROPIC_AUTH_TOKEN = $env:ANTHROPIC_AUTH_TOKEN
# Determine install path
$installPath = if ($global:CCC_HOME) {
$global:CCC_HOME
} else {
# Fallback to npm global path
$npmRoot = & npm root -g
Join-Path $npmRoot "claude-config-changer"
}
# Run the actual ccc command
& node (Join-Path $installPath "bin\ccc.js") @Arguments
# Check if the command was successful
if ($LASTEXITCODE -eq 0) {
# Reload the PowerShell profile to get new environment variables
$profilePath = $PROFILE
# Try different profile locations
if (Test-Path $profilePath) {
. $profilePath | Out-Null
} elseif (Test-Path "$HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1") {
. "$HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" | Out-Null
} elseif (Test-Path "$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1") {
. "$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" | Out-Null
}
# Check if environment actually changed
if ($OLD_ANTHROPIC_BASE_URL -ne $env:ANTHROPIC_BASE_URL) {
Write-Host ""
Write-Host "[OK] Configuration reloaded in current shell!" -ForegroundColor Green
Write-Host "New API URL: $env:ANTHROPIC_BASE_URL" -ForegroundColor Cyan
}
}
}
# ccs launcher: ccs [claude args] - Claude Code Starter
function ccs {
param(
[Parameter(ValueFromRemainingArguments=$true)]
[string[]]$Arguments
)
if ($Arguments -contains "--help" -or $Arguments -contains "-h") {
Write-Host "Usage: ccs [claude args]"
Write-Host " ccs - Start Claude with current config"
Write-Host " ccs --help - Show Claude help"
return
}
# Determine install path
$installPath = if ($global:CCC_HOME) {
$global:CCC_HOME
} else {
# Fallback to npm global path
$npmRoot = & npm root -g
Join-Path $npmRoot "claude-config-changer"
}
# Run our Node launcher
& node (Join-Path $installPath "bin\ccs.js") @Arguments
}
# Functions are automatically available when this script is dot-sourced
# No need for Export-ModuleMember in a regular script