easy-command 2.0.1 → 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 +18 -7
- package/README_CN.md +18 -7
- package/install.sh +88 -8
- package/package.json +1 -1
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
|
-
|
|
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
|
|
@@ -46,6 +53,8 @@ easy-command repair -y
|
|
|
46
53
|
easy-command update -y
|
|
47
54
|
```
|
|
48
55
|
|
|
56
|
+
If you do not want a global npm installation, replace `easy-command` in the examples with `npx easy-command`.
|
|
57
|
+
|
|
49
58
|
## What you get
|
|
50
59
|
|
|
51
60
|
- A clean `agnoster` prompt with your user, path, Git branch, and working-tree status.
|
|
@@ -81,11 +90,13 @@ bash install.sh -y --no-chsh
|
|
|
81
90
|
# Remove only the configuration block managed by easy-command
|
|
82
91
|
bash install.sh --uninstall
|
|
83
92
|
|
|
84
|
-
# Enable optional
|
|
85
|
-
bash install.sh -y --with-
|
|
93
|
+
# Enable optional fuzzy search and Git aliases
|
|
94
|
+
bash install.sh -y --with-fzf --with-git-aliases
|
|
86
95
|
```
|
|
87
96
|
|
|
88
|
-
`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.
|
|
89
100
|
|
|
90
101
|
## Requirements
|
|
91
102
|
|
|
@@ -119,13 +130,13 @@ bash install.sh -y
|
|
|
119
130
|
For production, pin a release tag instead of running `main` directly:
|
|
120
131
|
|
|
121
132
|
```bash
|
|
122
|
-
npx easy-command@2.0.
|
|
133
|
+
npx easy-command@2.0.4 -y
|
|
123
134
|
```
|
|
124
135
|
|
|
125
136
|
Or, without npm:
|
|
126
137
|
|
|
127
138
|
```bash
|
|
128
|
-
curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.
|
|
139
|
+
curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.4/install.sh | bash -s -- -y
|
|
129
140
|
```
|
|
130
141
|
|
|
131
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
|
-
|
|
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 安装
|
|
@@ -46,6 +53,8 @@ easy-command repair -y
|
|
|
46
53
|
easy-command update -y
|
|
47
54
|
```
|
|
48
55
|
|
|
56
|
+
如不希望全局安装 npm 包,将示例中的 `easy-command` 替换为 `npx easy-command` 即可。
|
|
57
|
+
|
|
49
58
|
## 安装后即可使用
|
|
50
59
|
|
|
51
60
|
- `agnoster` 提示符:显示用户名、当前路径、Git 分支和工作区状态。
|
|
@@ -81,11 +90,13 @@ bash install.sh -y --no-chsh
|
|
|
81
90
|
# 仅删除 easy-command 管理的 .zshrc 配置区块
|
|
82
91
|
bash install.sh --uninstall
|
|
83
92
|
|
|
84
|
-
#
|
|
85
|
-
bash install.sh -y --with-
|
|
93
|
+
# 启用可选的模糊搜索和 Git 快捷操作
|
|
94
|
+
bash install.sh -y --with-fzf --with-git-aliases
|
|
86
95
|
```
|
|
87
96
|
|
|
88
|
-
`zoxide`
|
|
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` 命令仍可使用。
|
|
89
100
|
|
|
90
101
|
## 系统要求
|
|
91
102
|
|
|
@@ -119,13 +130,13 @@ bash install.sh -y
|
|
|
119
130
|
生产环境建议固定到发布标签,而不是直接使用 `main`:
|
|
120
131
|
|
|
121
132
|
```bash
|
|
122
|
-
npx easy-command@2.0.
|
|
133
|
+
npx easy-command@2.0.4 -y
|
|
123
134
|
```
|
|
124
135
|
|
|
125
136
|
或者不使用 npm:
|
|
126
137
|
|
|
127
138
|
```bash
|
|
128
|
-
curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.
|
|
139
|
+
curl -fsSL https://raw.githubusercontent.com/UnionSchool/easy-command/v2.0.4/install.sh | bash -s -- -y
|
|
129
140
|
```
|
|
130
141
|
|
|
131
142
|
## 许可
|
package/install.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
set -Eeuo pipefail
|
|
4
4
|
|
|
5
|
-
readonly VERSION='2.0.
|
|
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=
|
|
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
|
-
--
|
|
43
|
-
--
|
|
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-.
|
|
@@ -110,7 +112,9 @@ write_file() {
|
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
determine_target_home() {
|
|
113
|
-
|
|
115
|
+
if command -v getent >/dev/null 2>&1; then
|
|
116
|
+
TARGET_HOME="$(getent passwd "$TARGET_USER" | cut -d: -f6 2>/dev/null || true)"
|
|
117
|
+
fi
|
|
114
118
|
if [[ -z "$TARGET_HOME" && "$(uname -s)" == 'Darwin' ]]; then
|
|
115
119
|
TARGET_HOME="$(dscl . -read "/Users/$TARGET_USER" NFSHomeDirectory | awk '{print $2}')"
|
|
116
120
|
fi
|
|
@@ -187,6 +191,17 @@ install_packages() {
|
|
|
187
191
|
esac
|
|
188
192
|
}
|
|
189
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
|
+
|
|
190
205
|
ensure_repository() {
|
|
191
206
|
local repository="$1"
|
|
192
207
|
local destination="$2"
|
|
@@ -301,6 +316,60 @@ EOF
|
|
|
301
316
|
# easy-command: zoxide
|
|
302
317
|
if command -v zoxide >/dev/null 2>&1; then
|
|
303
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
|
+
}
|
|
304
373
|
fi
|
|
305
374
|
EOF
|
|
306
375
|
fi
|
|
@@ -364,7 +433,14 @@ change_login_shell() {
|
|
|
364
433
|
|
|
365
434
|
local zsh_path
|
|
366
435
|
zsh_path="$(command -v zsh)"
|
|
367
|
-
grep -qx "$zsh_path" /etc/shells
|
|
436
|
+
if ! grep -qx "$zsh_path" /etc/shells; then
|
|
437
|
+
if [[ -x /bin/zsh ]] && grep -qx '/bin/zsh' /etc/shells; then
|
|
438
|
+
warn "$zsh_path is not listed in /etc/shells; using /bin/zsh as the login shell."
|
|
439
|
+
zsh_path='/bin/zsh'
|
|
440
|
+
else
|
|
441
|
+
fail "$zsh_path is not listed in /etc/shells. Use --no-chsh or add the path to /etc/shells first."
|
|
442
|
+
fi
|
|
443
|
+
fi
|
|
368
444
|
run_as_root chsh -s "$zsh_path" "$TARGET_USER"
|
|
369
445
|
}
|
|
370
446
|
|
|
@@ -384,7 +460,9 @@ doctor() {
|
|
|
384
460
|
local configured_shell=''
|
|
385
461
|
|
|
386
462
|
info "Checking easy-command for $TARGET_USER"
|
|
387
|
-
|
|
463
|
+
if command -v getent >/dev/null 2>&1; then
|
|
464
|
+
configured_shell="$(getent passwd "$TARGET_USER" | cut -d: -f7 2>/dev/null || true)"
|
|
465
|
+
fi
|
|
388
466
|
if [[ -z "$configured_shell" && "$(uname -s)" == 'Darwin' ]]; then
|
|
389
467
|
configured_shell="$(dscl . -read "/Users/$TARGET_USER" UserShell | awk '{print $2}')"
|
|
390
468
|
fi
|
|
@@ -454,6 +532,7 @@ parse_args() {
|
|
|
454
532
|
;;
|
|
455
533
|
--no-chsh) CHANGE_LOGIN_SHELL=false ;;
|
|
456
534
|
--dry-run) DRY_RUN=true ;;
|
|
535
|
+
--global) GLOBAL_INSTALL=true ;;
|
|
457
536
|
--with-zoxide) ENABLE_ZOXIDE=true ;;
|
|
458
537
|
--without-zoxide) ENABLE_ZOXIDE=false ;;
|
|
459
538
|
--with-fzf) ENABLE_FZF=true ;;
|
|
@@ -487,11 +566,12 @@ main() {
|
|
|
487
566
|
;;
|
|
488
567
|
install)
|
|
489
568
|
confirm "Install easy-command $VERSION for $TARGET_USER?"
|
|
569
|
+
install_global_package
|
|
490
570
|
install_packages
|
|
491
571
|
ensure_repositories
|
|
572
|
+
change_login_shell
|
|
492
573
|
write_zshrc_block
|
|
493
574
|
configure_git_aliases
|
|
494
|
-
change_login_shell
|
|
495
575
|
info "Installed easy-command $VERSION for $TARGET_USER. Reconnect or run: exec zsh -l"
|
|
496
576
|
;;
|
|
497
577
|
repair)
|