Skip to content

Commit 1d1d6fe

Browse files
committed
consolidate tools under ~/shell, replace nvm with fnm, Go to userspace [minor-release]
- Replace nvm with fnm (Node version manager) as a LanguageRuntime - Move Go SDK to ~/shell/go-sdk/ (no more sudo on macOS) - Move GOPATH to ~/shell/go/ - Move gcloud CLI to ~/shell/gcloud-sdk/ - Move nuclei-templates to ~/shell/nuclei-templates/ - Add UV_TOOL_DIR and UV_TOOL_BIN_DIR under ~/shell/ - Add NUCLEI_TEMPLATES_DIR env var - Add Go and fnm/Node cheatsheets - Move configs/ to internal/configs/ - Consolidate HTTP client into utils/http.go - Remove sudo requirement for Go (zero sudo on macOS) - Renumber init phases (merge Go into regular runtimes) - Add combined v1.3.0 migration script - Update rcfile, README, and clean command
1 parent 670aa33 commit 1d1d6fe

25 files changed

Lines changed: 490 additions & 179 deletions

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A single Go binary (`cps`) to initialize, manage, and update a complete CLI-driv
1212

1313
- **CLI utilities** - bat, fd, ripgrep, lsd, jq, yq, fzf, sd, gron, sq, and more
1414
- **Cloud CLIs** - AWS CLI, Azure CLI, gcloud CLI
15-
- **Language runtimes** - Go SDK, Python 3.14 (via uv), Rust (via rustup), Node.js LTS (via nvm)
15+
- **Language runtimes** - Go SDK, Python 3.14 (via uv), Rust (via rustup), Node.js LTS (via fnm)
1616
- **Editor & shell** - Neovim (0.11+) with NvChad, spaceship-prompt, zsh plugins, tmux with TPM
1717
- **Config files** - complete `.zshrc`, tmux.conf, kitty.conf, aerospace.toml (macOS)
1818

@@ -111,7 +111,7 @@ cps extend --check <pack> # Check a pack for updates
111111
Print styled terminal cheat sheets for common tools tailored to the CPS environment.
112112

113113
```bash
114-
cps cheat <topic> # e.g., cps, uv, rust, tmux, nvim, fzf, regex
114+
cps cheat <topic> # e.g., cps, go, uv, fnm, rust, tmux, nvim, fzf, regex
115115
```
116116

117117
### `self-update`
@@ -147,14 +147,14 @@ cps clean
147147
- Running `cps init` is idempotent - it skips tools that are already at the latest version
148148
- Cloud CLIs (AWS, Azure, gcloud) require sudo on Linux for system-level installation
149149
- The `.zshrc` deployed by `cps init` is a complete replacement - it includes Oh My Zsh config, tool integrations and aliases
150-
- `cps clean` removes `~/shell`, `~/.tmux`, `~/.config/nvim`, `~/.nvm`, `~/nuclei-templates`, `~/google-cloud-sdk`, and `~/.config/cps` - it does not touch Oh My Zsh, deployed config files, or system packages
150+
- `cps clean` removes `~/shell`, `~/.tmux`, `~/.config/nvim`, and `~/.config/cps` - it does not touch Oh My Zsh, deployed config files, or system packages
151151
- If you previously had `bat` installed and it is somehow quite slow now to load, it's likely due to an outdated cache, which can be rebuilt with `bat cache --build`
152152

153153
## Deep Removal
154154

155155
The `cps clean` command performs a superficial cleanup of CPS-managed directories. For a full removal of everything CPS installs, follow these steps:
156156

157-
**Step 1** - Run `cps clean` to remove the primary managed directories (`~/shell`, `~/.tmux`, `~/.config/nvim`, `~/.nvm`, `~/nuclei-templates`, `~/google-cloud-sdk`, `~/.config/cps`):
157+
**Step 1** - Run `cps clean` to remove the primary managed directories (`~/shell`, `~/.tmux`, `~/.config/nvim`, `~/.config/cps`):
158158

159159
```bash
160160
cps clean
@@ -170,7 +170,7 @@ rm -rf \
170170
$HOME/.aerospace.toml \
171171
$HOME/.config/kitty/kitty.conf \
172172
$HOME/.local/share/nvim \
173-
&& sudo rm -rf /usr/local/go /usr/local/aws-cli /usr/local/bin/cps
173+
&& sudo rm -rf /usr/local/aws-cli /usr/local/bin/cps
174174
```
175175

176176
**Step 3** - Remove system packages installed by CPS:

internal/cheatsheet/cheatsheet.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ type Sheet struct {
1111

1212
var sheets = []Sheet{
1313
cpsSheet,
14+
goSheet,
1415
uvSheet,
16+
fnmSheet,
1517
rustSheet,
1618
tmuxSheet,
1719
nvimSheet,

internal/cheatsheet/cps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func buildCPSSheet() string {
3939

4040
// --- Other ---
4141
b.WriteString(headingStyle.Render("Other") + "\n")
42-
b.WriteString(cmdStyle.Render(" cps cheat <topic>") + " Cheat sheets (uv, rust, tmux, nvim, fzf, regex)\n")
42+
b.WriteString(cmdStyle.Render(" cps cheat <topic>") + " Cheat sheets (go, uv, fnm, rust, tmux, nvim, fzf, regex)\n")
4343
b.WriteString(cmdStyle.Render(" --gh-token <token>") + " GitHub PAT for private repos\n")
4444
b.WriteString(cmdStyle.Render(" --debug") + " Verbose debug logging\n")
4545
b.WriteString(cmdStyle.Render(" --for-ai") + " AI-friendly output (no color)\n")

internal/cheatsheet/fnm.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package cheatsheet
2+
3+
import "strings"
4+
5+
func buildFnmSheet() string {
6+
var b strings.Builder
7+
divider := dividerStyle.Render(strings.Repeat("─", 60))
8+
9+
b.WriteString(titleStyle.Render("fnm / Node.js Cheat Sheet") + "\n")
10+
b.WriteString(noteStyle.Render(" CPS paths: FNM_DIR=~/shell/fnm") + "\n")
11+
b.WriteString(noteStyle.Render(" Node versions and global packages live under FNM_DIR") + "\n\n")
12+
13+
// --- Version Management ---
14+
b.WriteString(headingStyle.Render("Version Management") + "\n")
15+
b.WriteString(cmdStyle.Render(" fnm install --lts") + " Install latest LTS version\n")
16+
b.WriteString(cmdStyle.Render(" fnm install <version>") + " Install a specific version\n")
17+
b.WriteString(cmdStyle.Render(" fnm use <version>") + " Switch to a version (current shell)\n")
18+
b.WriteString(cmdStyle.Render(" fnm default <version>") + " Set the default version\n")
19+
b.WriteString(cmdStyle.Render(" fnm current") + " Show active version\n")
20+
b.WriteString(cmdStyle.Render(" fnm list") + " List installed versions\n")
21+
b.WriteString(cmdStyle.Render(" fnm list-remote") + " List available versions\n")
22+
b.WriteString(cmdStyle.Render(" fnm uninstall <version>") + " Remove a version\n")
23+
b.WriteString(divider + "\n")
24+
25+
// --- Per-Project Versions ---
26+
b.WriteString(headingStyle.Render("Per-Project Versions") + "\n")
27+
b.WriteString(noteStyle.Render(" fnm auto-detects .node-version or .nvmrc in the project dir.") + "\n")
28+
b.WriteString(noteStyle.Render(" eval \"$(fnm env)\" in .zshrc enables auto-switching.") + "\n\n")
29+
b.WriteString(cmdStyle.Render(" echo 20 > .node-version") + " Pin project to Node 20.x\n")
30+
b.WriteString(cmdStyle.Render(" fnm use") + " Switch to project's pinned version\n")
31+
b.WriteString(divider + "\n")
32+
33+
// --- npm Basics ---
34+
b.WriteString(headingStyle.Render("npm — Package Management") + "\n")
35+
b.WriteString(cmdStyle.Render(" npm init -y") + " Create package.json\n")
36+
b.WriteString(cmdStyle.Render(" npm install") + " Install project dependencies\n")
37+
b.WriteString(cmdStyle.Render(" npm install <pkg>") + " Add a dependency\n")
38+
b.WriteString(cmdStyle.Render(" npm install -D <pkg>") + " Add a dev dependency\n")
39+
b.WriteString(cmdStyle.Render(" npm install -g <pkg>") + " Install globally\n")
40+
b.WriteString(cmdStyle.Render(" npm list -g --depth=0") + " List global packages\n")
41+
b.WriteString(cmdStyle.Render(" npm update") + " Update project dependencies\n")
42+
b.WriteString(divider + "\n")
43+
44+
// --- npx ---
45+
b.WriteString(headingStyle.Render("npx — Run Without Installing") + "\n")
46+
b.WriteString(cmdStyle.Render(" npx <pkg>") + " Run a package directly\n")
47+
b.WriteString(cmdStyle.Render(" npx <pkg>@<version>") + " Run a specific version\n")
48+
b.WriteString(divider + "\n")
49+
50+
// --- Key Concepts ---
51+
b.WriteString(headingStyle.Render("Key Concepts") + "\n")
52+
b.WriteString(" • " + cmdStyle.Render("fnm") + " manages Node versions — each version is isolated under FNM_DIR\n")
53+
b.WriteString(" • " + cmdStyle.Render("npm install -g") + " → global packages are per-Node-version\n")
54+
b.WriteString(" • " + cmdStyle.Render(".node-version") + " → auto-switches Node when entering a project dir\n")
55+
b.WriteString(" • " + cmdStyle.Render("cps install node") + " → updates fnm + Node LTS, preserves global npm packages\n")
56+
57+
return b.String()
58+
}
59+
60+
var fnmSheet = Sheet{
61+
Name: "fnm",
62+
Aliases: []string{"node", "npm"},
63+
Description: "fnm version manager, npm, and Node.js cheat sheet",
64+
Content: buildFnmSheet(),
65+
}

internal/cheatsheet/go.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package cheatsheet
2+
3+
import "strings"
4+
5+
func buildGoSheet() string {
6+
var b strings.Builder
7+
divider := dividerStyle.Render(strings.Repeat("─", 60))
8+
9+
b.WriteString(titleStyle.Render("Go Cheat Sheet") + "\n")
10+
b.WriteString(noteStyle.Render(" CPS paths: GOROOT=~/shell/go-sdk GOPATH=~/shell/go") + "\n")
11+
b.WriteString(noteStyle.Render(" Binaries from go install land in $GOPATH/bin/") + "\n\n")
12+
13+
// --- Build & Run ---
14+
b.WriteString(headingStyle.Render("Build & Run") + "\n")
15+
b.WriteString(cmdStyle.Render(" go build ./...") + " Build all packages\n")
16+
b.WriteString(cmdStyle.Render(" go build -o <name> .") + " Build with custom output name\n")
17+
b.WriteString(cmdStyle.Render(" go run .") + " Build and run main package\n")
18+
b.WriteString(divider + "\n")
19+
20+
// --- Testing ---
21+
b.WriteString(headingStyle.Render("Testing") + "\n")
22+
b.WriteString(cmdStyle.Render(" go test ./...") + " Run all tests\n")
23+
b.WriteString(cmdStyle.Render(" go test -v -run <regex> ./...") + " Verbose + filter by name\n")
24+
b.WriteString(cmdStyle.Render(" go test -cover -race ./...") + " Coverage + race detector\n")
25+
b.WriteString(divider + "\n")
26+
27+
// --- Tools ---
28+
b.WriteString(headingStyle.Render("Tools") + "\n")
29+
b.WriteString(cmdStyle.Render(" go vet ./...") + " Report likely mistakes\n")
30+
b.WriteString(cmdStyle.Render(" gofmt -w .") + " Format all files in place\n")
31+
b.WriteString(cmdStyle.Render(" go install <pkg>@latest") + " Install a Go binary tool\n")
32+
b.WriteString(divider + "\n")
33+
34+
// --- Go Tool ---
35+
b.WriteString(headingStyle.Render("Go Tool — Built-in Analyzers") + "\n")
36+
b.WriteString(cmdStyle.Render(" go tool pprof <profile>") + " Analyze CPU/memory profiles\n")
37+
b.WriteString(cmdStyle.Render(" go tool nm <binary>") + " List symbols in a binary\n")
38+
b.WriteString(cmdStyle.Render(" go tool objdump <binary>") + " Disassemble a binary\n")
39+
b.WriteString(cmdStyle.Render(" go tool bisect") + " Binary search for failure cause\n")
40+
b.WriteString(noteStyle.Render(" External tools (install first):") + "\n")
41+
b.WriteString(cmdStyle.Render(" go install golang.org/x/tools/cmd/deadcode@latest") + "\n")
42+
b.WriteString(cmdStyle.Render(" go tool deadcode ./...") + " Find unreachable functions\n")
43+
b.WriteString(divider + "\n")
44+
45+
// --- Cross Compilation ---
46+
b.WriteString(headingStyle.Render("Cross Compilation") + "\n")
47+
b.WriteString(cmdStyle.Render(" GOOS=linux GOARCH=amd64 go build -o app .") + "\n")
48+
b.WriteString(cmdStyle.Render(" GOOS=darwin GOARCH=arm64 go build -o app .") + "\n")
49+
b.WriteString(noteStyle.Render(" Common: GOOS=linux|darwin|windows GOARCH=amd64|arm64") + "\n")
50+
b.WriteString(divider + "\n")
51+
52+
// --- Build Flags ---
53+
b.WriteString(headingStyle.Render("Build Flags") + "\n")
54+
b.WriteString(cmdStyle.Render(" -ldflags \"-s -w\"") + " Strip debug info (smaller binary)\n")
55+
b.WriteString(cmdStyle.Render(" -ldflags \"-X main.ver=v1\"") + " Inject version at build time\n")
56+
b.WriteString(cmdStyle.Render(" CGO_ENABLED=0") + " Static binary (no C deps)\n")
57+
58+
return b.String()
59+
}
60+
61+
var goSheet = Sheet{
62+
Name: "go",
63+
Aliases: []string{"golang"},
64+
Description: "Go build, test, tools, and cross-compilation cheat sheet",
65+
Content: buildGoSheet(),
66+
}

internal/cheatsheet/uv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ func buildUVSheet() string {
5050

5151
// --- Tool Install ---
5252
b.WriteString(headingStyle.Render("Tool Install — Isolated CLI Tools") + "\n")
53-
b.WriteString(noteStyle.Render(" Each tool gets its own hidden venv (~/.local/share/uv/tools/<name>/).") + "\n")
54-
b.WriteString(noteStyle.Render(" CLI entry points are symlinked to ~/.local/bin/ (or --bin-dir).") + "\n")
53+
b.WriteString(noteStyle.Render(" Each tool gets its own isolated venv (~/shell/uv-tools/<name>/).") + "\n")
54+
b.WriteString(noteStyle.Render(" CLI entry points are symlinked to ~/shell/uv-tool-executables/.") + "\n")
5555
b.WriteString(noteStyle.Render(" Only works for packages with console_scripts entry points.") + "\n\n")
5656
b.WriteString(cmdStyle.Render(" uv tool install <pkg>") + " Install from PyPI\n")
5757
b.WriteString(cmdStyle.Render(" uv tool install <pkg> --bin-dir <path>") + "\n")

0 commit comments

Comments
 (0)