From 7dfc428d63e3764335c5f8645f09c48259bfdf5f Mon Sep 17 00:00:00 2001 From: smoido Date: Tue, 1 Sep 2026 21:43:57 +0300 Subject: [PATCH] Install straight from the repo with one piped command Piped in via irm | iex there is no checkout next to the script, so the installer now notices that and fetches the repository archive to %TEMP% itself. README documents the one-liner, the download-and-run variant for switches, and the clone path. Co-Authored-By: Claude Code --- README.md | 30 ++++++++++++++++++++++++++---- install.ps1 | 28 +++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c635a43..4e1a04a 100644 --- a/README.md +++ b/README.md @@ -288,17 +288,39 @@ this tool writes is referenced by it: ## Setup +One line, on any machine that can reach the repo (PowerShell 5.1 is fine): + ```powershell -cd c:\Users\smoido\Projects\cli\claude-code-switcher +irm https://git.nebulm.com/smoido/claude-mode/raw/branch/master/install.ps1 | iex +``` + +Piped in like that there is no checkout, so the installer fetches the +repository archive to `%TEMP%` and installs from it. To pass switches +(`-Force`, `-SkipKeyPrompt`), download first and run the file: + +```powershell +irm https://git.nebulm.com/smoido/claude-mode/raw/branch/master/install.ps1 -OutFile install.ps1 +.\install.ps1 -Force +``` + +Or clone it — the normal path if you want to read the code and pull updates: + +```powershell +git clone https://git.nebulm.com/smoido/claude-mode.git +cd claude-mode .\install.ps1 ``` -Installs to `~/.claude-mode/` (ACL: you only), drops `claude-mode.cmd` into -`~/.local/bin` (already on your User PATH, next to `claude.exe`), and adds a -marked block to `~/Documents/WindowsPowerShell/profile.ps1`. +All three install the same way: to `~/.claude-mode/` (ACL: you only), dropping +`claude-mode.cmd` into `~/.local/bin` (already on your User PATH, next to +`claude.exe`), and adding a marked block to +`~/Documents/WindowsPowerShell/profile.ps1`. `~/.claude/settings.json` is **not** touched by the installer — only by an actual mode switch, which backs it up to `~/.claude-mode/backups/` first (last 20 kept). +Re-running any of them is a safe upgrade: scripts are overwritten, existing +presets are kept unless `-Force` is passed. + If the profile doesn't load: `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`. ## Restarting sessions diff --git a/install.ps1 b/install.ps1 index 6f380b0..ea27f54 100644 --- a/install.ps1 +++ b/install.ps1 @@ -18,7 +18,33 @@ param( Set-StrictMode -Version 1.0 $ErrorActionPreference = 'Stop' -$src = Split-Path -Parent $MyInvocation.MyCommand.Path +$repoUrl = 'https://git.nebulm.com/smoido/claude-mode' + +# Running from a checkout, the source is the files next to this script. Piped +# in (irm ... | iex) there is no script file and no checkout, so fetch the +# repository archive and install from that instead. +$src = $null +if ($PSScriptRoot -and (Test-Path -LiteralPath (Join-Path $PSScriptRoot 'claude-mode.ps1'))) { + $src = $PSScriptRoot +} +else { + [Net.ServicePointManager]::SecurityProtocol = + [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + $tmp = Join-Path $env:TEMP ('claude-mode-src-' + [IO.Path]::GetRandomFileName().Replace('.', '')) + New-Item -ItemType Directory -Path $tmp -Force | Out-Null + $zip = Join-Path $tmp 'repo.zip' + Write-Host "no local checkout found - fetching source from $repoUrl" -ForegroundColor Cyan + Invoke-WebRequest -Uri "$repoUrl/archive/master.zip" -OutFile $zip -UseBasicParsing + Expand-Archive -LiteralPath $zip -DestinationPath $tmp + # Forgejo nests everything under a repo-named folder; find it wherever it is. + $extracted = Get-ChildItem -LiteralPath $tmp -Directory | + Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName 'claude-mode.ps1') } | + Select-Object -First 1 + if ($extracted) { $src = $extracted.FullName } + elseif (Test-Path -LiteralPath (Join-Path $tmp 'claude-mode.ps1')) { $src = $tmp } + else { throw 'archive did not contain claude-mode.ps1 - repo layout changed?' } +} + $root = Join-Path $env:USERPROFILE '.claude-mode' Write-Host "installing claude-mode -> $root" -ForegroundColor Cyan