easy-command 2.0.6 → 2.0.8

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/README.md CHANGED
@@ -95,7 +95,7 @@ bash install.sh --uninstall
95
95
  bash install.sh -y --with-fzf
96
96
  ```
97
97
 
98
- `zoxide` is installed by default. It enables `z <keyword>` directory jumping and `z add <directory>` (or `z a <directory>`) for manually recording a directory. Use `--without-zoxide` to disable it. `fzf` adds fuzzy history and file searching. Git aliases are added by default, including `git st`, `git br`, `git sw`, `git ci`, `git cam`, `git lg`, `git la`, `git lb`, and `git ec-status`; existing aliases are never overwritten. Use `--without-git-aliases` to skip or remove aliases managed by easy-command.
98
+ `zoxide` is installed by default. It enables `z <keyword>` directory jumping and `z add <directory>` (or `z a <directory>`) for manually recording a directory. Directories are recorded only through `z add`, `z a`, `ec add`, or `ec a`; normal jumps never add a directory automatically. Use `--without-zoxide` to disable it. `fzf` adds fuzzy history and file searching. Git aliases are added by default, including `git st`, `git br`, `git sw`, `git ci`, `git cam`, `git lg`, `git la`, `git lb`, and `git ec-status`; existing aliases are never overwritten. Use `--without-git-aliases` to skip or remove aliases managed by easy-command.
99
99
 
100
100
  For a unified interface, use `ec <keyword>` to jump, `ec add <directory>` (or `ec a <directory>`) to record a directory, `ec list` (or `ec l`) to view entries, and `ec del <directory>` (or `ec remove <directory>`) to remove one. `ec doctor`, `ec repair`, `ec update`, `ec install`, `ec uninstall`, and `ec --dry-run` run the matching easy-command maintenance operation. `z` remains available for zoxide compatibility.
101
101
 
@@ -131,13 +131,13 @@ bash install.sh -y
131
131
  For production, pin a release tag instead of running `main` directly:
132
132
 
133
133
  ```bash
134
- npx easy-command@2.0.6 -y
134
+ npx easy-command@2.0.8 -y
135
135
  ```
136
136
 
137
137
  Or, without npm:
138
138
 
139
139
  ```bash
140
- curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.6/install.sh | bash -s -- -y
140
+ curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.8/install.sh | bash -s -- -y
141
141
  ```
142
142
 
143
143
  ## License
package/README_CN.md CHANGED
@@ -95,7 +95,7 @@ bash install.sh --uninstall
95
95
  bash install.sh -y --with-fzf
96
96
  ```
97
97
 
98
- 默认安装 `zoxide`,可使用 `z <关键词>` 跳转目录,也支持 `z add <目录>` 或 `z a <目录>` 手动记录目录;使用 `--without-zoxide` 可关闭。`fzf` 提供历史命令和文件的模糊搜索;默认添加 Git 快捷操作,包括 `git st`、`git br`、`git sw`、`git ci`、`git cam`、`git lg`、`git la`、`git lb` 和 `git ec-status` 等,不会覆盖已有同名别名。使用 `--without-git-aliases` 可跳过或移除项目管理的快捷方式。
98
+ 默认安装 `zoxide`,可使用 `z <关键词>` 跳转目录,也支持 `z add <目录>` 或 `z a <目录>` 手动记录目录;目录仅会通过 `z add`、`z a`、`ec add` 或 `ec a` 显式记录,普通跳转不会自动添加目录。使用 `--without-zoxide` 可关闭。`fzf` 提供历史命令和文件的模糊搜索;默认添加 Git 快捷操作,包括 `git st`、`git br`、`git sw`、`git ci`、`git cam`、`git lg`、`git la`、`git lb` 和 `git ec-status` 等,不会覆盖已有同名别名。使用 `--without-git-aliases` 可跳过或移除项目管理的快捷方式。
99
99
 
100
100
  统一入口使用 `ec`:`ec <关键词>` 跳转目录,`ec add <目录>` 或 `ec a <目录>` 记录目录,`ec list` 或 `ec l` 查看记录,`ec del <目录>` 或 `ec remove <目录>` 删除记录;`ec doctor`、`ec repair`、`ec update`、`ec install`、`ec uninstall` 和 `ec --dry-run` 执行对应的 easy-command 维护操作。为兼容 zoxide,原有 `z` 命令仍可使用。
101
101
 
@@ -131,13 +131,13 @@ bash install.sh -y
131
131
  生产环境建议固定到发布标签,而不是直接使用 `main`:
132
132
 
133
133
  ```bash
134
- npx easy-command@2.0.6 -y
134
+ npx easy-command@2.0.8 -y
135
135
  ```
136
136
 
137
137
  或者不使用 npm:
138
138
 
139
139
  ```bash
140
- curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.6/install.sh | bash -s -- -y
140
+ curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.8/install.sh | bash -s -- -y
141
141
  ```
142
142
 
143
143
  ## 许可
package/bin/easy-command CHANGED
@@ -10,4 +10,4 @@ while [[ -h "$source_path" ]]; do
10
10
  done
11
11
 
12
12
  package_directory="$(cd -P "$(dirname "$source_path")/.." && pwd)"
13
- exec "$package_directory/install.sh" "$@"
13
+ exec env EASY_COMMAND_NPM_CLI=1 "$package_directory/install.sh" "$@"
package/install.sh CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -Eeuo pipefail
4
4
 
5
- readonly VERSION='2.0.6'
5
+ readonly VERSION='2.0.8'
6
6
  readonly BEGIN_MARKER='# >>> easy-command zsh >>>'
7
7
  readonly END_MARKER='# <<< easy-command zsh <<<'
8
8
  readonly BASE_DIR_NAME='.easy-command'
@@ -48,6 +48,7 @@ Options:
48
48
  --with-git-aliases Add non-conflicting global Git aliases (default).
49
49
  --without-git-aliases
50
50
  Remove global Git aliases managed by easy-command.
51
+ --version, -v Print the easy-command version.
51
52
  --uninstall Remove only the easy-command managed .zshrc block.
52
53
  --help, -h Show this help.
53
54
  EOF
@@ -202,6 +203,24 @@ install_global_package() {
202
203
  fi
203
204
  }
204
205
 
206
+ update_global_package() {
207
+ [[ "${EASY_COMMAND_NPM_CLI:-}" == '1' ]] || return 0
208
+ [[ "${EASY_COMMAND_SELF_UPDATED:-}" != '1' ]] || return 0
209
+ command -v npm >/dev/null 2>&1 || {
210
+ warn 'npm is unavailable; skipped easy-command CLI upgrade.'
211
+ return 0
212
+ }
213
+
214
+ if "$DRY_RUN"; then
215
+ command_preview npm install -g easy-command@latest
216
+ return 0
217
+ fi
218
+
219
+ info 'Updating easy-command CLI to the latest npm version...'
220
+ npm install -g easy-command@latest || fail 'Unable to update easy-command CLI. Check npm permissions and registry settings, then retry.'
221
+ exec env EASY_COMMAND_NPM_CLI=1 EASY_COMMAND_SELF_UPDATED=1 easy-command update --yes --user "$TARGET_USER"
222
+ }
223
+
205
224
  ensure_repository() {
206
225
  local repository="$1"
207
226
  local destination="$2"
@@ -315,15 +334,22 @@ EOF
315
334
 
316
335
  # easy-command: zoxide
317
336
  if command -v zoxide >/dev/null 2>&1; then
318
- eval "$(zoxide init zsh)"
337
+ # Paths are recorded only through `ec add` / `ec a`; never implicitly after cd.
338
+ eval "$(zoxide init zsh --no-cmd --hook none)"
339
+
340
+ function __easy_command_jump() {
341
+ local target
342
+ target="$(command zoxide query --exclude "$PWD" -- "$@")" || return 1
343
+ builtin cd -- "$target"
344
+ }
319
345
 
320
- # Keep zoxide's normal jump behavior and add a short command for recording paths.
346
+ # Keep z for zoxide compatibility, but record paths only when explicitly requested.
321
347
  function z() {
322
348
  if [[ "$1" == 'add' || "$1" == 'a' ]]; then
323
349
  shift
324
350
  command zoxide add "$@"
325
351
  else
326
- __zoxide_z "$@"
352
+ __easy_command_jump "$@"
327
353
  fi
328
354
  }
329
355
 
@@ -337,7 +363,7 @@ if command -v zoxide >/dev/null 2>&1; then
337
363
  command npx easy-command "$@"
338
364
  fi
339
365
  ;;
340
- --dry-run)
366
+ --dry-run|-v|--version)
341
367
  if (( $+commands[easy-command] )); then
342
368
  command easy-command "$@"
343
369
  else
@@ -366,7 +392,7 @@ if command -v zoxide >/dev/null 2>&1; then
366
392
  ' ec --dry-run'
367
393
  ;;
368
394
  *)
369
- __zoxide_z "$@"
395
+ __easy_command_jump "$@"
370
396
  ;;
371
397
  esac
372
398
  }
@@ -560,6 +586,10 @@ parse_args() {
560
586
  --with-git-aliases) ENABLE_GIT_ALIASES=true ;;
561
587
  --without-git-aliases) ENABLE_GIT_ALIASES=false ;;
562
588
  --uninstall) ACTION='uninstall' ;;
589
+ --version|-v)
590
+ printf '%s\n' "$VERSION"
591
+ exit 0
592
+ ;;
563
593
  --help|-h)
564
594
  usage
565
595
  exit 0
@@ -609,6 +639,7 @@ main() {
609
639
  update)
610
640
  CHANGE_LOGIN_SHELL=false
611
641
  confirm "Update easy-command repositories for $TARGET_USER?"
642
+ update_global_package
612
643
  ensure_repositories
613
644
  update_repositories
614
645
  write_zshrc_block
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-command",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Configure a polished Zsh terminal with one command.",
5
5
  "license": "MIT",
6
6
  "bin": {