@n-seiji/nuthatch 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@n-seiji/nuthatch",
3
+ "version": "0.1.0",
4
+ "description": "git worktree manager (hop)",
5
+ "homepage": "https://github.com/n-seiji/nuthatch#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/n-seiji/nuthatch/issues"
8
+ },
9
+ "license": "GPL-3.0-only",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/n-seiji/nuthatch.git"
13
+ },
14
+ "bin": {
15
+ "hop": "dist/cli.js"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "shell"
20
+ ],
21
+ "type": "module",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "scripts": {
26
+ "build": "bun build ./src/cli.ts --outfile dist/cli.js --target node --format esm",
27
+ "typecheck": "tsc --noEmit",
28
+ "lint": "oxlint .",
29
+ "lint:fix": "oxlint . --fix",
30
+ "format": "oxfmt --write .",
31
+ "format:check": "oxfmt --check .",
32
+ "test": "bun test"
33
+ },
34
+ "dependencies": {
35
+ "citty": "^0.1.6",
36
+ "ink": "^7.1.1",
37
+ "react": "^19.2.8",
38
+ "valibot": "^1.4.2"
39
+ },
40
+ "devDependencies": {
41
+ "@types/bun": "latest",
42
+ "@types/react": "^19.2.18",
43
+ "oxfmt": "^0.66.0",
44
+ "oxlint": "^1.81.0",
45
+ "react-devtools-core": "^7.0.1",
46
+ "typescript": "^5.6.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=20"
50
+ }
51
+ }
package/shell/init.zsh ADDED
@@ -0,0 +1,46 @@
1
+ # nuthatch shell integration for zsh.
2
+ # Usage: eval "$(hop init zsh)"
3
+ #
4
+ # This file is a reference copy of the template embedded in
5
+ # src/commands/init.ts (renderInit). Keep the two in sync.
6
+ hop() {
7
+ if [[ "$1" == "-" ]]; then
8
+ cd - > /dev/null || return $?
9
+ return 0
10
+ fi
11
+
12
+ local should_cd=1
13
+ case "$1" in
14
+ ls|rm|clean|init) should_cd=0 ;;
15
+ --) ;; # "hop -- <branch>" escapes a reserved word; still a jump, so cd.
16
+ "")
17
+ # Bare "hop": picker on a real terminal (cd on success), ls fallback
18
+ # otherwise (prints a listing, not a path — don't cd). fd 2/0 are what
19
+ # the child inherits unchanged; fd 1 is about to become the capture
20
+ # pipe below, so it can't be checked here — this mirrors hop's own
21
+ # isTTY() check (stderr + stdin), not stdout.
22
+ if [[ -t 2 && -t 0 ]]; then
23
+ should_cd=1
24
+ else
25
+ should_cd=0
26
+ fi
27
+ ;;
28
+ --*) should_cd=0 ;;
29
+ esac
30
+
31
+ # "status" is a zsh read-only special parameter (mirrors $?); using it as a
32
+ # local name fails with "read-only variable: status". Use "rc" instead, and
33
+ # declare it before the command substitution so the exit code isn't
34
+ # clobbered by "local"'s own exit status.
35
+ local out rc
36
+ out="$(command hop "$@")"
37
+ rc=$?
38
+
39
+ if [[ $rc -eq 0 && $should_cd -eq 1 && -n "$out" ]]; then
40
+ cd -- "$out" || return $?
41
+ elif [[ -n "$out" ]]; then
42
+ print -r -- "$out"
43
+ fi
44
+
45
+ return $rc
46
+ }