Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ Codigest는 AI 모델을 호출하지 않습니다. 모델에게 보낼 자료

## 설치

빌드된 바이너리를 설치합니다. Python이 필요 없습니다. Windows (PowerShell):
빌드된 바이너리를 설치합니다. Python이 필요 없습니다. Windows (cmd 또는 PowerShell):

<!-- test windows -->
```powershell
irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
```

Linux, macOS, Termux:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ your machine.

## Install

Prebuilt binary, no Python needed. Windows (PowerShell):
Prebuilt binary, no Python needed. Windows (cmd or PowerShell):

<!-- test windows -->
```powershell
irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
```

Linux, macOS and Termux:
Expand Down
122 changes: 63 additions & 59 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -1,74 +1,78 @@
# Installs cdg, the Codigest binary, from a GitHub release.
#
# irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
# powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
#
# CDG_VERSION=0.12.1 picks a release instead of the latest one. CDG_INSTALL_DIR picks the
# folder; the default one is added to the user PATH, a chosen one is left to you.
# Running it again replaces the installed binary.

$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
# irm | iex runs this in your shell's scope; the script block keeps its settings and variables
# out of it. Only the PATH changes are meant to stay.
& {
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

$repo = 'NaNIsaac/codigest'
# Only an x64 build exists; Windows on ARM runs it under emulation.
$target = 'x86_64-pc-windows-msvc'
$repo = 'NaNIsaac/codigest'
# Only an x64 build exists; Windows on ARM runs it under emulation.
$target = 'x86_64-pc-windows-msvc'

if ($env:CDG_VERSION) {
$tag = 'rust-v' + ($env:CDG_VERSION -replace '^(rust-)?v', '')
$release = Invoke-RestMethod "https://api.github.com/repos/$repo/releases/tags/$tag"
} else {
# not releases/latest: a GitHub release for a Python v* tag would take that spot
$release = (Invoke-RestMethod "https://api.github.com/repos/$repo/releases?per_page=30") |
Where-Object { -not $_.draft -and -not $_.prerelease -and $_.tag_name -like 'rust-v*' } |
Select-Object -First 1
if (-not $release) { throw "No rust-v* release found in $repo." }
}
$asset = $release.assets | Where-Object { $_.name -like "codigest-*-$target.zip" } | Select-Object -First 1
if (-not $asset) {
throw "Release $($release.tag_name) has no $target archive."
}
if ($env:CDG_VERSION) {
$tag = 'rust-v' + ($env:CDG_VERSION -replace '^(rust-)?v', '')
$release = Invoke-RestMethod "https://api.github.com/repos/$repo/releases/tags/$tag"
} else {
# not releases/latest: a GitHub release for a Python v* tag would take that spot
$release = (Invoke-RestMethod "https://api.github.com/repos/$repo/releases?per_page=30") |
Where-Object { -not $_.draft -and -not $_.prerelease -and $_.tag_name -like 'rust-v*' } |
Select-Object -First 1
if (-not $release) { throw "No rust-v* release found in $repo." }
}
$asset = $release.assets | Where-Object { $_.name -like "codigest-*-$target.zip" } | Select-Object -First 1
if (-not $asset) {
throw "Release $($release.tag_name) has no $target archive."
}

$custom = [bool]$env:CDG_INSTALL_DIR
$dir = if ($custom) { $env:CDG_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\codigest' }
$custom = [bool]$env:CDG_INSTALL_DIR
$dir = if ($custom) { $env:CDG_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\codigest' }

$work = Join-Path ([IO.Path]::GetTempPath()) ("cdg-install-" + [guid]::NewGuid())
New-Item -ItemType Directory -Force $work | Out-Null
try {
$zip = Join-Path $work $asset.name
Write-Host "Downloading $($asset.name)"
Invoke-WebRequest $asset.browser_download_url -OutFile $zip
# GitHub records each asset's SHA-256 as "sha256:<hex>"
if ("$($asset.digest)" -notmatch '^sha256:([0-9a-f]{64})$') {
throw "Release $($release.tag_name) has no SHA-256 digest for $($asset.name)."
$work = Join-Path ([IO.Path]::GetTempPath()) ("cdg-install-" + [guid]::NewGuid())
New-Item -ItemType Directory -Force $work | Out-Null
try {
$zip = Join-Path $work $asset.name
Write-Host "Downloading $($asset.name)"
Invoke-WebRequest $asset.browser_download_url -OutFile $zip
# GitHub records each asset's SHA-256 as "sha256:<hex>"
if ("$($asset.digest)" -notmatch '^sha256:([0-9a-f]{64})$') {
throw "Release $($release.tag_name) has no SHA-256 digest for $($asset.name)."
}
$fs = [IO.File]::OpenRead($zip)
try { $got = -join ([Security.Cryptography.SHA256]::Create().ComputeHash($fs) | ForEach-Object { $_.ToString('x2') }) } finally { $fs.Dispose() }
if ($got -ne $Matches[1]) { throw "Checksum mismatch for $($asset.name): expected $($Matches[1]), got $got." }
Expand-Archive $zip $work
$exe = Get-ChildItem $work -Recurse -Filter cdg.exe | Select-Object -First 1
New-Item -ItemType Directory -Force $dir | Out-Null
Copy-Item $exe.FullName (Join-Path $dir 'cdg.exe') -Force
} finally {
Remove-Item $work -Recurse -Force -ErrorAction SilentlyContinue
}
$fs = [IO.File]::OpenRead($zip)
try { $got = -join ([Security.Cryptography.SHA256]::Create().ComputeHash($fs) | ForEach-Object { $_.ToString('x2') }) } finally { $fs.Dispose() }
if ($got -ne $Matches[1]) { throw "Checksum mismatch for $($asset.name): expected $($Matches[1]), got $got." }
Expand-Archive $zip $work
$exe = Get-ChildItem $work -Recurse -Filter cdg.exe | Select-Object -First 1
New-Item -ItemType Directory -Force $dir | Out-Null
Copy-Item $exe.FullName (Join-Path $dir 'cdg.exe') -Force
} finally {
Remove-Item $work -Recurse -Force -ErrorAction SilentlyContinue
}

$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$onPath = ($userPath -split ';') -contains $dir
if (-not $custom -and -not $onPath) {
[Environment]::SetEnvironmentVariable('Path', ($userPath.TrimEnd(';') + ";$dir").TrimStart(';'), 'User')
Write-Host "Added $dir to your user PATH."
}
if (-not (($env:Path -split ';') -contains $dir)) {
$env:Path = "$env:Path;$dir"
}
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$onPath = ($userPath -split ';') -contains $dir
if (-not $custom -and -not $onPath) {
[Environment]::SetEnvironmentVariable('Path', ($userPath.TrimEnd(';') + ";$dir").TrimStart(';'), 'User')
Write-Host "Added $dir to your user PATH."
}
if (-not (($env:Path -split ';') -contains $dir)) {
$env:Path = "$env:Path;$dir"
}

Write-Host "Installed $(& (Join-Path $dir 'cdg.exe') --version) to $dir"
# The Python package (uv tool, pipx) also provides cdg; whichever is first on PATH runs.
$first = Get-Command cdg -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
if ($first -and -not ((Split-Path $first.Source) -ieq $dir.TrimEnd('\'))) {
Write-Warning "cdg in new shells is $($first.Source) ($(& $first.Source --version)), not this install. Remove one (e.g. 'uv tool uninstall codigest') or put $dir earlier on PATH."
}
if ($custom -and -not $onPath) {
Write-Host "Add $dir to PATH to run cdg from anywhere."
Write-Host "Installed $(& (Join-Path $dir 'cdg.exe') --version) to $dir"
# The Python package (uv tool, pipx) also provides cdg; whichever is first on PATH runs.
$first = Get-Command cdg -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
if ($first -and -not ((Split-Path $first.Source) -ieq $dir.TrimEnd('\'))) {
Write-Warning "cdg in new shells is $($first.Source) ($(& $first.Source --version)), not this install. Remove one (e.g. 'uv tool uninstall codigest') or put $dir earlier on PATH."
}
if ($custom -and -not $onPath) {
Write-Host "Add $dir to PATH to run cdg from anywhere."
}
Write-Host "Next: cdg term install (captures command output in new shells)"
}
Write-Host "Next: cdg term install (captures command output in new shells)"
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ else
Darwin-x86_64) target=x86_64-apple-darwin ;;
Darwin-arm64) target=aarch64-apple-darwin ;;
MINGW* | MSYS* | CYGWIN*)
echo "On Windows, run in PowerShell: irm https://raw.githubusercontent.com/$repo/main/install.ps1 | iex" >&2
echo "On Windows, run in cmd or PowerShell: powershell -ExecutionPolicy Bypass -c \"irm -useb https://raw.githubusercontent.com/$repo/main/install.ps1 | iex\"" >&2
exit 1
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ programs that read and write the same data: the terminal capture store, `.codige
Windows (PowerShell), to `%LOCALAPPDATA%\Programs\codigest` and your user `PATH`:

```powershell
irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
```

Linux, macOS and Termux, to `~/.local/bin` (`$PREFIX/bin` in Termux):
Expand Down
2 changes: 1 addition & 1 deletion site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
windowsLabel: Windows
unixLabel: Linux / macOS / Termux
pythonLabel: Python (uv)
windows: 'irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex'
windows: 'powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"'
unix: 'curl -fsSL https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.sh | sh'
python: 'uv tool install codigest'
copy: Copy
Expand Down
4 changes: 2 additions & 2 deletions site/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Prebuilt binary (recommended)

One native binary, no Python needed. Windows (PowerShell):
One native binary, no Python needed. Windows (cmd or PowerShell):

```powershell
irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
```

Linux, macOS and Termux:
Expand Down
2 changes: 1 addition & 1 deletion site/ko/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
windowsLabel: Windows
unixLabel: Linux / macOS / Termux
pythonLabel: Python (uv)
windows: 'irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex'
windows: 'powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"'
unix: 'curl -fsSL https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.sh | sh'
python: 'uv tool install codigest'
copy: 복사
Expand Down
4 changes: 2 additions & 2 deletions site/ko/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## 빌드된 바이너리 (권장)

네이티브 바이너리 하나이고 Python이 필요 없습니다. Windows (PowerShell):
네이티브 바이너리 하나이고 Python이 필요 없습니다. Windows (cmd 또는 PowerShell):

```powershell
irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
```

Linux, macOS, Termux:
Expand Down
2 changes: 1 addition & 1 deletion site/ko/rust-port.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Python 빌드의 모든 명령을 Rust로 옮겼고, 빌드된 바이너리가 C
Windows(PowerShell)에서는 설치 스크립트가 `cdg.exe`를 `%LOCALAPPDATA%\Programs\codigest`에 넣고 그 폴더를 사용자 `PATH`에 추가합니다.

```powershell
irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
```

Linux, macOS, Termux에서는 `cdg`를 `~/.local/bin`(Termux는 `$PREFIX/bin`)에 설치합니다.
Expand Down
2 changes: 1 addition & 1 deletion site/rust-port.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Both builds install a command called `cdg`, so keep one of them on `PATH`. They
On Windows (PowerShell), the installer puts `cdg.exe` in `%LOCALAPPDATA%\Programs\codigest` and adds that folder to your user `PATH`:

```powershell
irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
powershell -ExecutionPolicy Bypass -c "irm -useb https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex"
```

On Linux, macOS and Termux, it installs `cdg` to `~/.local/bin` (`$PREFIX/bin` in Termux):
Expand Down
Loading