shellwise 0.1.1 → 0.1.3
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 +23 -14
- package/package.json +2 -1
- package/scripts/setup.sh +31 -11
- package/src/index.ts +8 -8
package/README.md
CHANGED
|
@@ -31,11 +31,17 @@ Tab/Shift+Tab to navigate, Enter to select, Esc to dismiss
|
|
|
31
31
|
|
|
32
32
|
## Install
|
|
33
33
|
|
|
34
|
+
> **Important:** This is a CLI tool — install it **globally**.
|
|
35
|
+
|
|
34
36
|
```bash
|
|
37
|
+
# Recommended
|
|
35
38
|
bun install -g shellwise
|
|
39
|
+
|
|
40
|
+
# Or with npm
|
|
41
|
+
npm install -g shellwise
|
|
36
42
|
```
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
Shell integration is auto-injected into your `~/.zshrc` or `~/.bashrc` on install. Restart your terminal to activate.
|
|
39
45
|
|
|
40
46
|
### Manual setup
|
|
41
47
|
|
|
@@ -43,10 +49,10 @@ If auto-setup didn't work, add to your shell config:
|
|
|
43
49
|
|
|
44
50
|
```bash
|
|
45
51
|
# ~/.zshrc
|
|
46
|
-
eval "$(
|
|
52
|
+
eval "$(shellwise init zsh)"
|
|
47
53
|
|
|
48
54
|
# ~/.bashrc
|
|
49
|
-
eval "$(
|
|
55
|
+
eval "$(shellwise init bash)"
|
|
50
56
|
```
|
|
51
57
|
|
|
52
58
|
## Usage
|
|
@@ -76,29 +82,31 @@ Press `Ctrl+R` to open full fuzzy search:
|
|
|
76
82
|
|
|
77
83
|
### Commands
|
|
78
84
|
|
|
85
|
+
Both `shellwise` and `sw` work as the command name:
|
|
86
|
+
|
|
79
87
|
```bash
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
shellwise search [--query <text>] # Interactive fuzzy search (Ctrl+R)
|
|
89
|
+
shellwise suggest --query <text> # Get top suggestion (used by shell hook)
|
|
90
|
+
shellwise add --command <cmd> # Save a command to history
|
|
91
|
+
shellwise init <zsh|bash> # Output shell integration script
|
|
92
|
+
shellwise import [zsh|bash] # Import existing shell history
|
|
93
|
+
shellwise stats # Show usage statistics
|
|
94
|
+
shellwise prune --days <n> # Remove entries older than n days
|
|
95
|
+
shellwise daemon start|stop|status # Manage background daemon
|
|
88
96
|
```
|
|
89
97
|
|
|
90
98
|
### Import existing history
|
|
91
99
|
|
|
92
100
|
```bash
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
shellwise import zsh # Import from ~/.zsh_history
|
|
102
|
+
shellwise import bash # Import from ~/.bash_history
|
|
95
103
|
```
|
|
96
104
|
|
|
97
105
|
## Architecture
|
|
98
106
|
|
|
99
107
|
```
|
|
100
108
|
┌──────────────┐ TCP (persistent) ┌──────────────────┐
|
|
101
|
-
│ Zsh/Bash │◄────────────────────────►│
|
|
109
|
+
│ Zsh/Bash │◄────────────────────────►│ shellwise daemon │
|
|
102
110
|
│ (shell) │ ~1-3ms round-trip │ (Bun process) │
|
|
103
111
|
└──────────────┘ └────────┬─────────┘
|
|
104
112
|
│
|
|
@@ -132,6 +140,7 @@ sw import bash # Import from ~/.bash_history
|
|
|
132
140
|
|
|
133
141
|
```bash
|
|
134
142
|
bun remove -g shellwise
|
|
143
|
+
# or: npm uninstall -g shellwise
|
|
135
144
|
```
|
|
136
145
|
|
|
137
146
|
Shell integration is automatically removed from your config on uninstall.
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shellwise",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Smart command history with inline auto-suggest and fuzzy search for your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
+
"shellwise": "./bin/sw.js",
|
|
7
8
|
"sw": "./bin/sw.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
package/scripts/setup.sh
CHANGED
|
@@ -10,15 +10,33 @@ DIM='\033[2m'
|
|
|
10
10
|
BOLD='\033[1m'
|
|
11
11
|
RESET='\033[0m'
|
|
12
12
|
|
|
13
|
+
# Detect if this is a local (not global) install
|
|
14
|
+
if [[ -z "$(command -v shellwise 2>/dev/null)" && -z "$(command -v sw 2>/dev/null)" ]]; then
|
|
15
|
+
# Check if we're inside node_modules (local install)
|
|
16
|
+
if [[ "$PWD" == *"node_modules"* ]] || [[ "${INIT_CWD:-}" == *"node_modules"* ]]; then
|
|
17
|
+
echo -e "${YELLOW}${BOLD}[shellwise]${RESET} This is a CLI tool — install it globally:"
|
|
18
|
+
echo -e " ${BOLD}bun install -g shellwise${RESET}"
|
|
19
|
+
echo -e " ${DIM}or: npm install -g shellwise${RESET}"
|
|
20
|
+
exit 0
|
|
21
|
+
fi
|
|
22
|
+
fi
|
|
23
|
+
|
|
13
24
|
MARKER="# shellwise shell integration"
|
|
14
25
|
|
|
15
|
-
# Detect
|
|
26
|
+
# Detect shellwise binary path (prefer 'shellwise' over 'sw' to avoid conflicts)
|
|
16
27
|
SW_BIN=""
|
|
17
|
-
if command -v
|
|
18
|
-
SW_BIN="
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
|
|
28
|
+
if command -v shellwise &>/dev/null; then
|
|
29
|
+
SW_BIN="shellwise"
|
|
30
|
+
elif command -v sw &>/dev/null; then
|
|
31
|
+
# Verify it's actually shellwise, not another tool
|
|
32
|
+
if sw --help 2>&1 | grep -q "shellwise" 2>/dev/null; then
|
|
33
|
+
SW_BIN="sw"
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Try common global bin paths
|
|
38
|
+
if [[ -z "$SW_BIN" ]]; then
|
|
39
|
+
for p in "$HOME/.bun/bin/shellwise" "$HOME/.local/bin/shellwise" "$(npm prefix -g 2>/dev/null)/bin/shellwise"; do
|
|
22
40
|
if [[ -x "$p" ]]; then
|
|
23
41
|
SW_BIN="$p"
|
|
24
42
|
break
|
|
@@ -27,8 +45,8 @@ else
|
|
|
27
45
|
fi
|
|
28
46
|
|
|
29
47
|
if [[ -z "$SW_BIN" ]]; then
|
|
30
|
-
echo -e "${YELLOW}[shellwise]${RESET} Could not find
|
|
31
|
-
echo ' eval "$(
|
|
48
|
+
echo -e "${YELLOW}[shellwise]${RESET} Could not find shellwise binary. Add manually:"
|
|
49
|
+
echo ' eval "$(shellwise init zsh)" # add to ~/.zshrc'
|
|
32
50
|
exit 0
|
|
33
51
|
fi
|
|
34
52
|
|
|
@@ -75,14 +93,16 @@ case "$SHELL_NAME" in
|
|
|
75
93
|
*)
|
|
76
94
|
echo -e "${YELLOW}[shellwise]${RESET} Unsupported shell: $SHELL_NAME"
|
|
77
95
|
echo ' Supported: zsh, bash'
|
|
78
|
-
echo ' Add manually: eval "$(
|
|
96
|
+
echo ' Add manually: eval "$(shellwise init zsh)"'
|
|
79
97
|
exit 0
|
|
80
98
|
;;
|
|
81
99
|
esac
|
|
82
100
|
|
|
83
101
|
# Start daemon for fast suggest
|
|
84
|
-
if command -v
|
|
85
|
-
|
|
102
|
+
if command -v shellwise &>/dev/null; then
|
|
103
|
+
shellwise daemon start &>/dev/null || true
|
|
104
|
+
elif [[ -n "$SW_BIN" ]]; then
|
|
105
|
+
$SW_BIN daemon start &>/dev/null || true
|
|
86
106
|
fi
|
|
87
107
|
|
|
88
108
|
echo -e "${GREEN}${BOLD}[shellwise]${RESET} Restart your terminal or run: ${BOLD}source ~/.${SHELL_NAME}rc${RESET}"
|
package/src/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ function parseFlags(args: string[]): Record<string, string> {
|
|
|
29
29
|
function printHelp(): void {
|
|
30
30
|
console.log(`shellwise - Smart command history with fuzzy search
|
|
31
31
|
|
|
32
|
-
Usage:
|
|
32
|
+
Usage: shellwise <command> [options] (or: sw <command>)
|
|
33
33
|
|
|
34
34
|
Commands:
|
|
35
35
|
search [--query <text>] Interactive fuzzy search (Ctrl+R)
|
|
@@ -42,8 +42,8 @@ Commands:
|
|
|
42
42
|
daemon start|stop|status Manage background daemon (faster suggest)
|
|
43
43
|
|
|
44
44
|
Setup:
|
|
45
|
-
Add to ~/.zshrc: eval "$(
|
|
46
|
-
Add to ~/.bashrc: eval "$(
|
|
45
|
+
Add to ~/.zshrc: eval "$(shellwise init zsh)"
|
|
46
|
+
Add to ~/.bashrc: eval "$(shellwise init bash)"
|
|
47
47
|
|
|
48
48
|
Features:
|
|
49
49
|
- Auto-save: commands are recorded automatically
|
|
@@ -80,7 +80,7 @@ async function main(): Promise<void> {
|
|
|
80
80
|
case "add": {
|
|
81
81
|
const flags = parseFlags(args.slice(1));
|
|
82
82
|
if (!flags.command) {
|
|
83
|
-
console.error("Usage:
|
|
83
|
+
console.error("Usage: shellwise add --command <cmd>");
|
|
84
84
|
process.exit(1);
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -106,10 +106,10 @@ async function main(): Promise<void> {
|
|
|
106
106
|
case "init": {
|
|
107
107
|
const shell = args[1];
|
|
108
108
|
if (!shell) {
|
|
109
|
-
console.error("Usage:
|
|
109
|
+
console.error("Usage: shellwise init <zsh|bash>");
|
|
110
110
|
process.exit(1);
|
|
111
111
|
}
|
|
112
|
-
runInit(shell, "
|
|
112
|
+
runInit(shell, "shellwise");
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -139,7 +139,7 @@ async function main(): Promise<void> {
|
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
// Fork to background
|
|
142
|
-
const proc = Bun.spawn(["
|
|
142
|
+
const proc = Bun.spawn(["shellwise", "daemon", "_run"], {
|
|
143
143
|
stdio: ["ignore", "ignore", "ignore"],
|
|
144
144
|
// @ts-ignore - Bun supports detached
|
|
145
145
|
detached: true,
|
|
@@ -179,7 +179,7 @@ async function main(): Promise<void> {
|
|
|
179
179
|
break;
|
|
180
180
|
}
|
|
181
181
|
default:
|
|
182
|
-
console.error("Usage:
|
|
182
|
+
console.error("Usage: shellwise daemon start|stop|status");
|
|
183
183
|
process.exit(1);
|
|
184
184
|
}
|
|
185
185
|
break;
|