easy-command 2.0.2 → 2.0.4

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
@@ -10,10 +10,17 @@ Configure a polished Zsh terminal in one command.
10
10
 
11
11
  ## INSTALL
12
12
 
13
- ### npm
13
+ ### npm (recommended)
14
14
 
15
15
  ```bash
16
- npx easy-command -y
16
+ npm i -g easy-command
17
+ easy-command -y
18
+ ```
19
+
20
+ Or install globally and configure your terminal in one command:
21
+
22
+ ```bash
23
+ npx easy-command -y --global
17
24
  ```
18
25
 
19
26
  ### GitHub
@@ -34,19 +41,19 @@ exec zsh -l
34
41
 
35
42
  ```bash
36
43
  # Preview installation without changing your machine
37
- npx easy-command --dry-run
44
+ easy-command --dry-run
38
45
 
39
46
  # Check Shell, dependencies, managed repositories, and .zshrc configuration
40
- npx easy-command doctor
47
+ easy-command doctor
41
48
 
42
49
  # Restore missing managed files and configuration
43
- npx easy-command repair -y
50
+ easy-command repair -y
44
51
 
45
52
  # Safely update Oh My Zsh and managed plugins
46
- npx easy-command update -y
53
+ easy-command update -y
47
54
  ```
48
55
 
49
- `npx` runs the command without a global npm installation. If you prefer the shorter `easy-command` command, install it globally with `npm install -g easy-command`.
56
+ If you do not want a global npm installation, replace `easy-command` in the examples with `npx easy-command`.
50
57
 
51
58
  ## What you get
52
59
 
@@ -83,11 +90,13 @@ bash install.sh -y --no-chsh
83
90
  # Remove only the configuration block managed by easy-command
84
91
  bash install.sh --uninstall
85
92
 
86
- # Enable optional directory jumping, fuzzy search, and Git aliases
87
- bash install.sh -y --with-zoxide --with-fzf --with-git-aliases
93
+ # Enable optional fuzzy search and Git aliases
94
+ bash install.sh -y --with-fzf --with-git-aliases
88
95
  ```
89
96
 
90
- `zoxide` enables `z <keyword>` directory jumping. `fzf` adds fuzzy history and file searching. Git aliases use the non-conflicting `ec-` prefix, such as `git ec-status`; existing aliases are never overwritten.
97
+ `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 use the non-conflicting `ec-` prefix, such as `git ec-status`; existing aliases are never overwritten.
98
+
99
+ 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.
91
100
 
92
101
  ## Requirements
93
102
 
@@ -121,13 +130,13 @@ bash install.sh -y
121
130
  For production, pin a release tag instead of running `main` directly:
122
131
 
123
132
  ```bash
124
- npx easy-command@2.0.2 -y
133
+ npx easy-command@2.0.4 -y
125
134
  ```
126
135
 
127
136
  Or, without npm:
128
137
 
129
138
  ```bash
130
- curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.2/install.sh | bash -s -- -y
139
+ curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.4/install.sh | bash -s -- -y
131
140
  ```
132
141
 
133
142
  ## License
package/README_CN.md CHANGED
@@ -10,10 +10,17 @@
10
10
 
11
11
  ## 安装
12
12
 
13
- ### npm 安装
13
+ ### npm 安装(推荐)
14
14
 
15
15
  ```bash
16
- npx easy-command -y
16
+ npm i -g easy-command
17
+ easy-command -y
18
+ ```
19
+
20
+ 也可以一条命令完成全局安装和终端配置:
21
+
22
+ ```bash
23
+ npx easy-command -y --global
17
24
  ```
18
25
 
19
26
  ### GitHub 安装
@@ -34,19 +41,19 @@ exec zsh -l
34
41
 
35
42
  ```bash
36
43
  # 预览安装过程,不修改本机环境
37
- npx easy-command --dry-run
44
+ easy-command --dry-run
38
45
 
39
46
  # 检查 Shell、依赖、托管仓库和 .zshrc 配置
40
- npx easy-command doctor
47
+ easy-command doctor
41
48
 
42
49
  # 恢复缺失的托管文件和配置
43
- npx easy-command repair -y
50
+ easy-command repair -y
44
51
 
45
52
  # 安全更新 Oh My Zsh 和托管插件
46
- npx easy-command update -y
53
+ easy-command update -y
47
54
  ```
48
55
 
49
- `npx` 无需全局安装即可运行命令。若希望直接使用更短的 `easy-command` 命令,可执行 `npm install -g easy-command`。
56
+ 如不希望全局安装 npm 包,将示例中的 `easy-command` 替换为 `npx easy-command` 即可。
50
57
 
51
58
  ## 安装后即可使用
52
59
 
@@ -83,11 +90,13 @@ bash install.sh -y --no-chsh
83
90
  # 仅删除 easy-command 管理的 .zshrc 配置区块
84
91
  bash install.sh --uninstall
85
92
 
86
- # 启用可选的目录跳转、模糊搜索和 Git 快捷操作
87
- bash install.sh -y --with-zoxide --with-fzf --with-git-aliases
93
+ # 启用可选的模糊搜索和 Git 快捷操作
94
+ bash install.sh -y --with-fzf --with-git-aliases
88
95
  ```
89
96
 
90
- `zoxide` 提供 `z <关键词>` 目录跳转;`fzf` 提供历史命令和文件的模糊搜索;Git 快捷操作使用 `ec-` 前缀,例如 `git ec-status`,不会覆盖已有别名。
97
+ 默认安装 `zoxide`,可使用 `z <关键词>` 跳转目录,也支持 `z add <目录>` 或 `z a <目录>` 手动记录目录;使用 `--without-zoxide` 可关闭。`fzf` 提供历史命令和文件的模糊搜索;Git 快捷操作使用 `ec-` 前缀,例如 `git ec-status`,不会覆盖已有别名。
98
+
99
+ 统一入口使用 `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` 命令仍可使用。
91
100
 
92
101
  ## 系统要求
93
102
 
@@ -121,13 +130,13 @@ bash install.sh -y
121
130
  生产环境建议固定到发布标签,而不是直接使用 `main`:
122
131
 
123
132
  ```bash
124
- npx easy-command@2.0.2 -y
133
+ npx easy-command@2.0.4 -y
125
134
  ```
126
135
 
127
136
  或者不使用 npm:
128
137
 
129
138
  ```bash
130
- curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.2/install.sh | bash -s -- -y
139
+ curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.4/install.sh | bash -s -- -y
131
140
  ```
132
141
 
133
142
  ## 许可
package/install.sh CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -Eeuo pipefail
4
4
 
5
- readonly VERSION='2.0.2'
5
+ readonly VERSION='2.0.4'
6
6
  readonly BEGIN_MARKER='# >>> easy-command zsh >>>'
7
7
  readonly END_MARKER='# <<< easy-command zsh <<<'
8
8
  readonly BASE_DIR_NAME='.easy-command'
@@ -11,9 +11,10 @@ ACTION='install'
11
11
  ASSUME_YES=false
12
12
  CHANGE_LOGIN_SHELL=true
13
13
  DRY_RUN=false
14
- ENABLE_ZOXIDE='auto'
14
+ ENABLE_ZOXIDE=true
15
15
  ENABLE_FZF='auto'
16
16
  ENABLE_GIT_ALIASES='auto'
17
+ GLOBAL_INSTALL=false
17
18
  TARGET_USER="${SUDO_USER:-${USER}}"
18
19
  TARGET_HOME=''
19
20
 
@@ -39,8 +40,9 @@ Options:
39
40
  --user USER Configure this user. Defaults to the invoking user.
40
41
  --no-chsh Do not change the user's default login shell to zsh.
41
42
  --dry-run Preview changes without installing, writing files, or using sudo.
42
- --with-zoxide Enable optional zoxide directory jumping.
43
- --without-zoxide Disable zoxide in the managed configuration.
43
+ --global Install this easy-command version globally with npm first.
44
+ --with-zoxide Enable zoxide directory jumping (enabled by default).
45
+ --without-zoxide Do not install or enable zoxide.
44
46
  --with-fzf Enable optional fzf history and file searching.
45
47
  --without-fzf Disable fzf in the managed configuration.
46
48
  --with-git-aliases Add non-conflicting global Git aliases prefixed with ec-.
@@ -189,6 +191,17 @@ install_packages() {
189
191
  esac
190
192
  }
191
193
 
194
+ install_global_package() {
195
+ "$GLOBAL_INSTALL" || return 0
196
+ command -v npm >/dev/null 2>&1 || fail 'npm is required for --global. Install Node.js/npm first.'
197
+
198
+ if "$DRY_RUN"; then
199
+ command_preview npm install -g "easy-command@$VERSION"
200
+ else
201
+ npm install -g "easy-command@$VERSION"
202
+ fi
203
+ }
204
+
192
205
  ensure_repository() {
193
206
  local repository="$1"
194
207
  local destination="$2"
@@ -303,6 +316,60 @@ EOF
303
316
  # easy-command: zoxide
304
317
  if command -v zoxide >/dev/null 2>&1; then
305
318
  eval "$(zoxide init zsh)"
319
+
320
+ # Keep zoxide's normal jump behavior and add a short command for recording paths.
321
+ function z() {
322
+ if [[ "$1" == 'add' || "$1" == 'a' ]]; then
323
+ shift
324
+ command zoxide add "$@"
325
+ else
326
+ __zoxide_z "$@"
327
+ fi
328
+ }
329
+
330
+ # Unified easy-command directory interface. Keep z for zoxide compatibility.
331
+ function ec() {
332
+ case "$1" in
333
+ doctor|repair|update|install|uninstall)
334
+ if (( $+commands[easy-command] )); then
335
+ command easy-command "$@"
336
+ else
337
+ command npx easy-command "$@"
338
+ fi
339
+ ;;
340
+ --dry-run)
341
+ if (( $+commands[easy-command] )); then
342
+ command easy-command "$@"
343
+ else
344
+ command npx easy-command "$@"
345
+ fi
346
+ ;;
347
+ add|a)
348
+ shift
349
+ command zoxide add "$@"
350
+ ;;
351
+ list|ls|l)
352
+ shift
353
+ command zoxide query --list "$@"
354
+ ;;
355
+ del|remove)
356
+ shift
357
+ command zoxide remove "$@"
358
+ ;;
359
+ help|--help|-h)
360
+ printf '%s\n' \
361
+ 'Usage: ec <keyword>' \
362
+ ' ec add|a <directory>' \
363
+ ' ec list|ls|l [keyword]' \
364
+ ' ec del|remove <directory>' \
365
+ ' ec doctor|repair|update|install|uninstall' \
366
+ ' ec --dry-run'
367
+ ;;
368
+ *)
369
+ __zoxide_z "$@"
370
+ ;;
371
+ esac
372
+ }
306
373
  fi
307
374
  EOF
308
375
  fi
@@ -465,6 +532,7 @@ parse_args() {
465
532
  ;;
466
533
  --no-chsh) CHANGE_LOGIN_SHELL=false ;;
467
534
  --dry-run) DRY_RUN=true ;;
535
+ --global) GLOBAL_INSTALL=true ;;
468
536
  --with-zoxide) ENABLE_ZOXIDE=true ;;
469
537
  --without-zoxide) ENABLE_ZOXIDE=false ;;
470
538
  --with-fzf) ENABLE_FZF=true ;;
@@ -498,6 +566,7 @@ main() {
498
566
  ;;
499
567
  install)
500
568
  confirm "Install easy-command $VERSION for $TARGET_USER?"
569
+ install_global_package
501
570
  install_packages
502
571
  ensure_repositories
503
572
  change_login_shell
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-command",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Configure a polished Zsh terminal with one command.",
5
5
  "license": "MIT",
6
6
  "bin": {