aliasmate 1.6.1 → 2.0.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.
Files changed (203) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +61 -876
  3. package/dist/cli/completion.d.ts +5 -0
  4. package/dist/cli/completion.d.ts.map +1 -0
  5. package/dist/cli/completion.js +144 -0
  6. package/dist/cli/completion.js.map +1 -0
  7. package/dist/cli/manage.d.ts +20 -0
  8. package/dist/cli/manage.d.ts.map +1 -0
  9. package/dist/cli/manage.js +213 -0
  10. package/dist/cli/manage.js.map +1 -0
  11. package/dist/cli/run.d.ts +6 -0
  12. package/dist/cli/run.d.ts.map +1 -0
  13. package/dist/cli/run.js +46 -0
  14. package/dist/cli/run.js.map +1 -0
  15. package/dist/cli/save.d.ts +9 -0
  16. package/dist/cli/save.d.ts.map +1 -0
  17. package/dist/cli/save.js +52 -0
  18. package/dist/cli/save.js.map +1 -0
  19. package/dist/cli/transfer.d.ts +5 -0
  20. package/dist/cli/transfer.d.ts.map +1 -0
  21. package/dist/cli/transfer.js +118 -0
  22. package/dist/cli/transfer.js.map +1 -0
  23. package/dist/core/commands.d.ts +27 -0
  24. package/dist/core/commands.d.ts.map +1 -0
  25. package/dist/core/commands.js +194 -0
  26. package/dist/core/commands.js.map +1 -0
  27. package/dist/core/env.d.ts +9 -0
  28. package/dist/core/env.d.ts.map +1 -0
  29. package/dist/core/env.js +45 -0
  30. package/dist/core/env.js.map +1 -0
  31. package/dist/core/executor.d.ts +7 -0
  32. package/dist/core/executor.d.ts.map +1 -0
  33. package/dist/{utils → core}/executor.js +10 -46
  34. package/dist/core/executor.js.map +1 -0
  35. package/dist/core/history.d.ts +11 -0
  36. package/dist/core/history.d.ts.map +1 -0
  37. package/dist/core/history.js +117 -0
  38. package/dist/core/history.js.map +1 -0
  39. package/dist/core/recent.d.ts +14 -0
  40. package/dist/core/recent.d.ts.map +1 -0
  41. package/dist/core/recent.js +54 -0
  42. package/dist/core/recent.js.map +1 -0
  43. package/dist/core/runner.d.ts +13 -0
  44. package/dist/core/runner.d.ts.map +1 -0
  45. package/dist/core/runner.js +83 -0
  46. package/dist/core/runner.js.map +1 -0
  47. package/dist/core/store.d.ts +29 -0
  48. package/dist/core/store.d.ts.map +1 -0
  49. package/dist/core/store.js +131 -0
  50. package/dist/core/store.js.map +1 -0
  51. package/dist/core/types.d.ts +29 -0
  52. package/dist/core/types.d.ts.map +1 -0
  53. package/dist/core/types.js +3 -0
  54. package/dist/core/types.js.map +1 -0
  55. package/dist/core/validate.d.ts +6 -0
  56. package/dist/core/validate.d.ts.map +1 -0
  57. package/dist/core/validate.js +139 -0
  58. package/dist/core/validate.js.map +1 -0
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +169 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/ui/format.d.ts +16 -0
  64. package/dist/ui/format.d.ts.map +1 -0
  65. package/dist/ui/format.js +112 -0
  66. package/dist/ui/format.js.map +1 -0
  67. package/dist/ui/interactive.d.ts +6 -0
  68. package/dist/ui/interactive.d.ts.map +1 -0
  69. package/dist/ui/interactive.js +147 -0
  70. package/dist/ui/interactive.js.map +1 -0
  71. package/dist/ui/onboarding.d.ts +3 -0
  72. package/dist/ui/onboarding.d.ts.map +1 -0
  73. package/dist/ui/onboarding.js +82 -0
  74. package/dist/ui/onboarding.js.map +1 -0
  75. package/dist/ui/prompts.d.ts +14 -0
  76. package/dist/ui/prompts.d.ts.map +1 -0
  77. package/dist/ui/prompts.js +96 -0
  78. package/dist/ui/prompts.js.map +1 -0
  79. package/dist/ui/theme.d.ts +28 -0
  80. package/dist/ui/theme.d.ts.map +1 -0
  81. package/dist/ui/theme.js +43 -0
  82. package/dist/ui/theme.js.map +1 -0
  83. package/package.json +4 -5
  84. package/dist/cli.d.ts +0 -3
  85. package/dist/cli.d.ts.map +0 -1
  86. package/dist/cli.js +0 -252
  87. package/dist/cli.js.map +0 -1
  88. package/dist/commands/alias.d.ts +0 -30
  89. package/dist/commands/alias.d.ts.map +0 -1
  90. package/dist/commands/alias.js +0 -213
  91. package/dist/commands/alias.js.map +0 -1
  92. package/dist/commands/changelog.d.ts +0 -9
  93. package/dist/commands/changelog.d.ts.map +0 -1
  94. package/dist/commands/changelog.js +0 -72
  95. package/dist/commands/changelog.js.map +0 -1
  96. package/dist/commands/completion.d.ts +0 -17
  97. package/dist/commands/completion.d.ts.map +0 -1
  98. package/dist/commands/completion.js +0 -363
  99. package/dist/commands/completion.js.map +0 -1
  100. package/dist/commands/delete.d.ts +0 -14
  101. package/dist/commands/delete.d.ts.map +0 -1
  102. package/dist/commands/delete.js +0 -54
  103. package/dist/commands/delete.js.map +0 -1
  104. package/dist/commands/edit.d.ts +0 -16
  105. package/dist/commands/edit.d.ts.map +0 -1
  106. package/dist/commands/edit.js +0 -231
  107. package/dist/commands/edit.js.map +0 -1
  108. package/dist/commands/export.d.ts +0 -23
  109. package/dist/commands/export.d.ts.map +0 -1
  110. package/dist/commands/export.js +0 -122
  111. package/dist/commands/export.js.map +0 -1
  112. package/dist/commands/import.d.ts +0 -23
  113. package/dist/commands/import.d.ts.map +0 -1
  114. package/dist/commands/import.js +0 -235
  115. package/dist/commands/import.js.map +0 -1
  116. package/dist/commands/list.d.ts +0 -25
  117. package/dist/commands/list.d.ts.map +0 -1
  118. package/dist/commands/list.js +0 -58
  119. package/dist/commands/list.js.map +0 -1
  120. package/dist/commands/prev.d.ts +0 -15
  121. package/dist/commands/prev.d.ts.map +0 -1
  122. package/dist/commands/prev.js +0 -138
  123. package/dist/commands/prev.js.map +0 -1
  124. package/dist/commands/recent.d.ts +0 -24
  125. package/dist/commands/recent.d.ts.map +0 -1
  126. package/dist/commands/recent.js +0 -132
  127. package/dist/commands/recent.js.map +0 -1
  128. package/dist/commands/run.d.ts +0 -22
  129. package/dist/commands/run.d.ts.map +0 -1
  130. package/dist/commands/run.js +0 -217
  131. package/dist/commands/run.js.map +0 -1
  132. package/dist/commands/save.d.ts +0 -17
  133. package/dist/commands/save.d.ts.map +0 -1
  134. package/dist/commands/save.js +0 -232
  135. package/dist/commands/save.js.map +0 -1
  136. package/dist/commands/search.d.ts +0 -19
  137. package/dist/commands/search.d.ts.map +0 -1
  138. package/dist/commands/search.js +0 -113
  139. package/dist/commands/search.js.map +0 -1
  140. package/dist/commands/validate.d.ts +0 -10
  141. package/dist/commands/validate.d.ts.map +0 -1
  142. package/dist/commands/validate.js +0 -162
  143. package/dist/commands/validate.js.map +0 -1
  144. package/dist/storage/index.d.ts +0 -117
  145. package/dist/storage/index.d.ts.map +0 -1
  146. package/dist/storage/index.js +0 -262
  147. package/dist/storage/index.js.map +0 -1
  148. package/dist/utils/changelog.d.ts +0 -41
  149. package/dist/utils/changelog.d.ts.map +0 -1
  150. package/dist/utils/changelog.js +0 -192
  151. package/dist/utils/changelog.js.map +0 -1
  152. package/dist/utils/constants.d.ts +0 -48
  153. package/dist/utils/constants.d.ts.map +0 -1
  154. package/dist/utils/constants.js +0 -51
  155. package/dist/utils/constants.js.map +0 -1
  156. package/dist/utils/env.d.ts +0 -64
  157. package/dist/utils/env.d.ts.map +0 -1
  158. package/dist/utils/env.js +0 -199
  159. package/dist/utils/env.js.map +0 -1
  160. package/dist/utils/errors.d.ts +0 -30
  161. package/dist/utils/errors.d.ts.map +0 -1
  162. package/dist/utils/errors.js +0 -62
  163. package/dist/utils/errors.js.map +0 -1
  164. package/dist/utils/executor.d.ts +0 -33
  165. package/dist/utils/executor.d.ts.map +0 -1
  166. package/dist/utils/executor.js.map +0 -1
  167. package/dist/utils/formatters.d.ts +0 -30
  168. package/dist/utils/formatters.d.ts.map +0 -1
  169. package/dist/utils/formatters.js +0 -188
  170. package/dist/utils/formatters.js.map +0 -1
  171. package/dist/utils/history.d.ts +0 -37
  172. package/dist/utils/history.d.ts.map +0 -1
  173. package/dist/utils/history.js +0 -179
  174. package/dist/utils/history.js.map +0 -1
  175. package/dist/utils/llm-generator.d.ts +0 -21
  176. package/dist/utils/llm-generator.d.ts.map +0 -1
  177. package/dist/utils/llm-generator.js +0 -915
  178. package/dist/utils/llm-generator.js.map +0 -1
  179. package/dist/utils/onboarding.d.ts +0 -10
  180. package/dist/utils/onboarding.d.ts.map +0 -1
  181. package/dist/utils/onboarding.js +0 -316
  182. package/dist/utils/onboarding.js.map +0 -1
  183. package/dist/utils/paths.d.ts +0 -44
  184. package/dist/utils/paths.d.ts.map +0 -1
  185. package/dist/utils/paths.js +0 -115
  186. package/dist/utils/paths.js.map +0 -1
  187. package/dist/utils/prompts.d.ts +0 -66
  188. package/dist/utils/prompts.d.ts.map +0 -1
  189. package/dist/utils/prompts.js +0 -51
  190. package/dist/utils/prompts.js.map +0 -1
  191. package/dist/utils/recent.d.ts +0 -55
  192. package/dist/utils/recent.d.ts.map +0 -1
  193. package/dist/utils/recent.js +0 -102
  194. package/dist/utils/recent.js.map +0 -1
  195. package/dist/utils/validator.d.ts +0 -56
  196. package/dist/utils/validator.d.ts.map +0 -1
  197. package/dist/utils/validator.js +0 -413
  198. package/dist/utils/validator.js.map +0 -1
  199. package/dist/utils/version-checker.d.ts +0 -29
  200. package/dist/utils/version-checker.d.ts.map +0 -1
  201. package/dist/utils/version-checker.js +0 -191
  202. package/dist/utils/version-checker.js.map +0 -1
  203. package/whats-new.json +0 -202
package/README.md CHANGED
@@ -1,925 +1,110 @@
1
1
  # AliasMate
2
2
 
3
- A powerful CLI utility to save, manage, and re-run shell commands with their working directories. Never lose track of useful commands again!
3
+ Save shell commands with their working directories and re-run them from anywhere. Never lose a useful command again.
4
4
 
5
5
  [![Version](https://img.shields.io/npm/v/aliasmate.svg)](https://www.npmjs.com/package/aliasmate)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)](https://www.typescriptlang.org/)
8
- [![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
9
7
 
10
- ## Why Use AliasMate?
11
-
12
- As developers, we often spend time crafting complex commands, navigating to specific directories, and repeating the same sequences. AliasMate solves this by:
13
-
14
- - **Saving Time**: Quickly save and rerun frequently used commands without retyping them.
15
- - **Reducing Errors**: Execute commands in their correct directories, avoiding path-related mistakes.
16
- - **Boosting Productivity**: Focus on coding instead of remembering command syntax and locations.
17
- - **Sharing Knowledge**: Export and import commands to share workflows with your team.
18
- - **Organizing Workflows**: Keep your development environment clean and organized with named, reusable commands.
19
-
20
- Whether you're a solo developer or part of a team, AliasMate helps you streamline your terminal workflow and maintain consistency across projects.
21
-
22
- ## Features
23
-
24
- - 🚀 **Save previous commands** from shell history with one simple command
25
- - 📂 **Remember working directories** where commands should be executed
26
- - 🎯 **Path mode selection** - Choose between saved directory or current directory execution
27
- - 🌍 **Environment variable capture** - Save and restore environment variables with commands
28
- - 🔒 **Security-focused** - Automatic masking of sensitive variables (API keys, tokens)
29
- - ⚡ **Quick execution** of saved commands with optional path override
30
- - 🏷️ **Command aliases** - Create short aliases for frequently used commands
31
- - 📜 **Recent commands** - Track and quickly re-run recent commands with @N syntax
32
- - ⚙️ **Auto-completion** - Shell completion for bash, zsh, and fish
33
- - 🔍 **Dry-run mode** - Preview commands before execution with --dry-run flag
34
- - ✅ **Command validation** - Verify commands and directories when saving
35
- - 📊 **Output formatting** - Multiple formats (JSON, YAML, table, compact)
36
- - 📝 **Interactive save** with prompts for command and path
37
- - 📋 **List all saved commands** with their details
38
- - 🔎 **Search commands** by name, text, or directory
39
- - ✏️ **Edit commands** interactively with environment variable management
40
- - 🗑️ **Delete unwanted commands**
41
- - 📤 **Export/Import** commands for backup or sharing
42
- - 📜 **Changelog viewer** - View version history and cumulative changes
43
- - 🤖 **LLM Integration** - Default command to generate comprehensive documentation
44
- - 🎉 **Onboarding experience** - Welcome tour and upgrade notifications
45
- - 🎨 **Beautiful colored output** for better readability
46
- - 🔄 **Cross-platform** support (Linux, macOS, Windows)
47
-
48
- ## Installation
49
-
50
- Install globally via npm:
8
+ ## Install
51
9
 
52
10
  ```bash
53
11
  npm i -g aliasmate
54
12
  ```
55
13
 
56
- ## Shell Completion (Optional)
57
-
58
- AliasMate supports auto-completion for bash, zsh, and fish shells. This provides tab completion for commands, saved command names, and flags.
59
-
60
- ### Bash
61
-
62
- Add to your `~/.bashrc`:
63
- ```bash
64
- source <(aliasmate completion bash)
65
- ```
66
-
67
- Then reload:
68
- ```bash
69
- source ~/.bashrc
70
- ```
71
-
72
- ### Zsh
14
+ Requires Node.js 18+. Works on macOS, Linux, and Windows.
73
15
 
74
- Add to your `~/.zshrc`:
75
- ```bash
76
- source <(aliasmate completion zsh)
77
- ```
16
+ ## Quick start
78
17
 
79
- Then reload:
80
18
  ```bash
81
- source ~/.zshrc
82
- ```
83
-
84
- ### Fish
85
-
86
- Generate the completion file:
87
- ```bash
88
- aliasmate completion fish > ~/.config/fish/completions/aliasmate.fish
89
- ```
90
-
91
- Fish will automatically load it on next shell start.
92
-
93
- ### What Gets Completed
94
-
95
- - Main commands (run, list, save, etc.)
96
- - Your saved command names
97
- - Command flags and options
98
- - File paths for import/export
99
- - Format options (json, yaml, table, compact)
100
-
101
- **Example:**
102
- ```bash
103
- aliasmate ru<TAB> # Completes to "run"
104
- aliasmate run bu<TAB> # Completes to your saved "build" command
105
- aliasmate list --fo<TAB> # Completes to "--format"
106
- ```
107
-
108
- ## Shell Configuration (Recommended)
109
-
110
- For `aliasmate prev` to work reliably and capture commands immediately, configure your shell to write history in real-time:
111
-
112
- ### For zsh users (macOS default, Linux):
113
-
114
- Add to `~/.zshrc`:
115
- ```bash
116
- setopt INC_APPEND_HISTORY
117
- ```
118
-
119
- Then reload:
120
- ```bash
121
- source ~/.zshrc
122
- ```
123
-
124
- ### For bash users (Linux default, macOS optional):
125
-
126
- Add to `~/.bashrc`:
127
- ```bash
128
- PROMPT_COMMAND="history -a"
129
- ```
130
-
131
- Then reload:
132
- ```bash
133
- source ~/.bashrc
134
- ```
135
-
136
- ### Why is this needed?
137
-
138
- **Without this configuration**, shells only write commands to the history file when the shell exits. This means:
139
- - If you run `npm run dev` and press `^C` to cancel it, then immediately run `aliasmate prev`, the command won't be in the history file yet
140
- - You'll see older commands captured instead (like `clear` or previous commands)
141
-
142
- **With this configuration**, every command is written to history immediately after execution, making `aliasmate prev` work perfectly every time.
143
-
144
- ### Alternative: Use `aliasmate save`
145
-
146
- If you prefer not to configure shell history, you can always use the interactive save:
147
- ```bash
148
- aliasmate save
149
- # Then enter your command manually
150
- ```
151
-
152
- ## Getting Started
153
-
154
- 1. **Install AliasMate** using the command above.
155
- 2. **Welcome Tour**: On first run, you'll see a helpful welcome message and quick tour explaining how AliasMate works.
156
- 3. **Default LLM Command**: A default "llm" command is automatically created that generates comprehensive documentation for AI assistants.
157
- 4. **Save a command**: After running any useful command in your terminal, save it with `aliasmate prev <name>`. For example:
158
- ```bash
159
- npm run build
160
- aliasmate prev build
161
- ```
162
- 3. **Run the command**: From anywhere, execute it with `aliasmate run <name>`:
163
- ```bash
164
- aliasmate run build
165
- ```
166
- 4. **Explore more**: Use `aliasmate list` to see all saved commands, `aliasmate edit <name>` to modify them, and more!
167
-
168
- ## Usage
169
-
170
- ### Save the Previous Command
171
-
172
- Automatically capture the last command you ran:
173
-
174
- ```bash
175
- # After running any command, save it
176
- aliasmate prev <name>
177
- ```
178
-
179
- **Example:**
180
- ```bash
181
- npm run build
19
+ # Run any command, then save it under a name
20
+ npm run build -- --production
182
21
  aliasmate prev build
183
- # ✓ Saved command as "build"
184
- # Command: npm run build
185
- # Directory: /path/to/project
186
- ```
187
-
188
- ### Run a Saved Command
189
-
190
- Execute a saved command in its original directory:
191
22
 
192
- ```bash
193
- aliasmate run <name>
194
- ```
195
-
196
- Or override the directory:
197
-
198
- ```bash
199
- aliasmate run <name> .
200
- aliasmate run <name> /path/to/another/project
201
- ```
202
-
203
- **Dry-run mode** (preview without executing):
204
- ```bash
205
- aliasmate run <name> --dry-run
206
- aliasmate run <name> --dry-run --verbose
207
- ```
208
-
209
- **Run recent commands** by index:
210
- ```bash
211
- aliasmate run @0 # Run most recent command
212
- aliasmate run @1 # Run second most recent
213
- ```
214
-
215
- **Example:**
216
- ```bash
23
+ # Run it later, from any directory — it executes back in the project folder
217
24
  aliasmate run build
218
- # Running: npm run build
219
- # Directory: /path/to/project
220
- ```
221
-
222
- ### Save a Command Interactively
223
-
224
- Manually save a command with interactive prompts:
225
-
226
- ```bash
227
- aliasmate save
228
- ```
229
-
230
- You'll be prompted for:
231
- - Command name
232
- - Command to save
233
- - Working directory (defaults to current directory)
234
- - **Path mode** (NEW): Choose whether to run in saved directory or current directory
235
-
236
- ### Path Mode Feature
237
-
238
- AliasMate now supports two path modes for each saved command:
239
-
240
- #### Saved Directory Mode (Default)
241
- Commands always run in the directory where they were saved. Perfect for project-specific commands.
242
-
243
- ```bash
244
- # Save a build command for a specific project
245
- cd /path/to/my-project
246
- npm run build
247
- aliasmate prev build
248
-
249
- # Later, run from anywhere - it executes in /path/to/my-project
250
- cd ~
251
- aliasmate run build # Runs in /path/to/my-project
252
- ```
253
-
254
- #### Current Directory Mode
255
- Commands run in your current working directory. Ideal for general-purpose utilities.
256
-
257
- ```bash
258
- # Save a command with current directory mode
259
- aliasmate save
260
- # Enter name: lint
261
- # Enter command: eslint .
262
- # Enter directory: /any/path (doesn't matter)
263
- # Choose: Current Directory
264
-
265
- # Later, runs in whichever directory you're in
266
- cd /path/to/project-a
267
- aliasmate run lint # Lints project-a
268
-
269
- cd /path/to/project-b
270
- aliasmate run lint # Lints project-b
271
- ```
272
-
273
- You can change the path mode anytime using `aliasmate edit <name>`.
274
-
275
- ### Generate LLM Documentation
276
-
277
- AliasMate includes a default command that generates comprehensive documentation for AI assistants:
278
-
279
- ```bash
280
- aliasmate run llm
281
- ```
282
-
283
- This creates an `llm.txt` file in your current directory containing:
284
- - Complete feature documentation
285
- - All available commands and their usage
286
- - Best practices and examples
287
- - Integration tips for AI assistants
288
-
289
- Share this file with AI assistants like ChatGPT or Claude for better help with AliasMate!
290
-
291
- ### List All Saved Commands
292
-
293
- View all your saved commands:
294
-
295
- ```bash
296
- aliasmate list
297
- # or
298
- aliasmate ls
299
- ```
300
-
301
- **Output:**
302
- ```
303
- Saved commands (3):
304
-
305
- build
306
- Command: npm run build
307
- Directory: /path/to/project
308
-
309
- deploy
310
- Command: ./deploy.sh
311
- Directory: /path/to/scripts
312
-
313
- test
314
- Command: pytest tests/
315
- Directory: /path/to/python-project
316
- ```
317
-
318
- ### Edit a Saved Command
319
-
320
- Modify an existing command:
321
-
322
- ```bash
323
- aliasmate edit <name>
324
- ```
325
-
326
- Opens an interactive prompt to edit the command and directory.
327
-
328
- ### Delete a Saved Command
329
-
330
- Remove a command you no longer need:
331
-
332
- ```bash
333
- aliasmate delete <name>
334
- # or
335
- aliasmate rm <name>
336
- ```
337
-
338
- ### Export Commands
339
-
340
- Backup your commands to a JSON file:
341
-
342
- ```bash
343
- aliasmate export commands.json
344
- ```
345
-
346
- ### Import Commands
347
25
 
348
- Restore commands from a JSON file:
349
-
350
- ```bash
351
- aliasmate import commands.json
26
+ # Or just open the interactive menu
27
+ aliasmate
352
28
  ```
353
29
 
354
- If there are name conflicts, you'll be prompted to:
355
- - Overwrite existing commands
356
- - Skip imported commands
357
- - Rename imported commands
30
+ Running `aliasmate` with no arguments opens an interactive menu: browse your commands sorted by how often you use them, and run, edit, or delete with a couple of keystrokes.
358
31
 
359
- ### View Config Location
32
+ ## Commands
360
33
 
361
- See where your commands are stored:
34
+ | Command | Description |
35
+ |---------|-------------|
36
+ | `aliasmate` | Interactive menu (run/save/edit/delete/stats) |
37
+ | `aliasmate prev <name>` | Save your previous shell command |
38
+ | `aliasmate save` | Save a command interactively |
39
+ | `aliasmate run <name> [path]` | Run a saved command, optionally in a different directory |
40
+ | `aliasmate run @0` | Re-run your most recent command (`@1`, `@2`, …) |
41
+ | `aliasmate run <name> --dry-run [--verbose]` | Preview without executing |
42
+ | `aliasmate list` (`ls`) | List commands (`--format table\|json\|yaml\|compact`) |
43
+ | `aliasmate search <query>` (`find`) | Search by name, text, or directory |
44
+ | `aliasmate edit <name>` | Edit a command (text, directory, path mode, env vars) |
45
+ | `aliasmate delete <name>` (`rm`) | Delete a command (`-f` skips confirmation) |
46
+ | `aliasmate alias <short> <name>` | Create a shortcut alias (`--list`, `--remove <a>`) |
47
+ | `aliasmate recent` | Recently run commands with `@N` indices (`--clear`) |
48
+ | `aliasmate stats` | Usage statistics: most-used commands, total runs |
49
+ | `aliasmate validate [name]` | Check commands, directories, and env vars |
50
+ | `aliasmate export <file>` | Export to JSON/YAML — secrets masked |
51
+ | `aliasmate import <file>` | Import from JSON (backs up your config first) |
52
+ | `aliasmate completion install` | Install tab completion (bash/zsh/fish) |
53
+ | `aliasmate config` | Show where your data is stored |
362
54
 
363
- ```bash
364
- aliasmate config
365
- ```
366
-
367
- ### Environment Variables
55
+ ## Key features
368
56
 
369
- AliasMate can capture and restore environment variables along with your commands:
57
+ ### Path modes
58
+ Each command runs either in its **saved directory** (project commands like `build`) or in your **current directory** (general utilities like `lint`). Choose when saving; change anytime with `edit`.
370
59
 
371
- #### Capturing Environment Variables
60
+ ### Environment variables
61
+ When saving, you can capture user-defined env vars (`NODE_ENV`, `API_URL`, …) with the command — system noise like `PATH` is filtered out automatically. Variables whose names look sensitive (`KEY`, `TOKEN`, `SECRET`, `PASSWORD`, …) are masked in listings and exports, so sharing a team export never leaks secrets.
372
62
 
373
- When saving commands with `prev` or `save`, you'll be prompted to capture environment variables:
63
+ ### Safety
64
+ - `--dry-run` previews exactly what will execute, where, and with which env vars.
65
+ - Destructive-looking commands (`rm -rf`, `dd`, `mkfs`, …) get a warning before running.
66
+ - All writes to your config are atomic; a crash can never corrupt your data.
67
+ - `import` writes a timestamped backup of your existing config before touching it.
374
68
 
375
- ```bash
376
- NODE_ENV=production npm run build
377
- aliasmate prev build-prod
378
- # Would you like to capture current environment variables? (y/n)
379
- ```
69
+ ### Recent commands & stats
70
+ Every run is tracked. `aliasmate run @0` re-runs your latest command, `aliasmate recent` lists history, and `aliasmate stats` shows your most-used commands.
380
71
 
381
- **What Gets Captured:**
382
- - ✅ User-defined environment variables (like `NODE_ENV`, `API_URL`, `DEBUG`)
383
- - ❌ System variables are filtered out (like `PATH`, `HOME`, `USER`)
384
- - 🔒 Sensitive variables are automatically detected and masked
72
+ ## Shell setup (recommended)
385
73
 
386
- #### Security Features
74
+ `aliasmate prev` reads your shell history file, which most shells only flush on exit. For instant capture, enable real-time history:
387
75
 
388
- - **Automatic Detection**: Sensitive variables containing keywords like `KEY`, `SECRET`, `TOKEN`, `PASSWORD` are automatically identified
389
- - **Masked Exports**: When exporting, sensitive values are masked (e.g., `API_KEY=abc***xy`)
390
- - **Safe Sharing**: Share command exports with your team without exposing secrets
76
+ - **zsh** (`~/.zshrc`): `setopt INC_APPEND_HISTORY`
77
+ - **bash** (`~/.bashrc`): `PROMPT_COMMAND="history -a"`
78
+ - **fish / PowerShell**: already immediate by default
391
79
 
392
- #### Managing Environment Variables
80
+ Tab completion:
393
81
 
394
82
  ```bash
395
- # Edit a command to update environment variables
396
- aliasmate edit build-prod
397
- # Select which variables to keep or remove
398
-
399
- # View commands with their environment variables
400
- aliasmate list
401
- # Shows which commands have env vars saved
83
+ aliasmate completion install
402
84
  ```
403
85
 
404
- **Use Cases:**
405
- - Development/staging/production environment switching
406
- - API testing with different endpoints and tokens
407
- - Tool configuration (e.g., `DEBUG=*`, `VERBOSE=true`)
408
- - Multi-environment deployments
86
+ ## Where data lives
409
87
 
410
- **Example:**
411
- ```bash
412
- # Development setup
413
- NODE_ENV=development API_URL=http://localhost:3000 npm start
414
- aliasmate prev dev-server
88
+ `~/.config/aliasmate/` (override with the `ALIASMATE_HOME` environment variable):
415
89
 
416
- # Run anywhere - environment is restored
417
- aliasmate run dev-server
418
- # Restores NODE_ENV and API_URL automatically
419
- ```
90
+ - `config.json` your saved commands
91
+ - `metadata.json` — aliases and run history
420
92
 
421
- ### Version History & Changelog
422
-
423
- View what's new and see changes between versions:
424
-
425
- ```bash
426
- # View current version changes
427
- aliasmate changelog
428
-
429
- # View specific version
430
- aliasmate changelog --ver 1.3.0
431
-
432
- # View all changes between versions (upgrade path)
433
- aliasmate changelog --from 1.2.0 --to 1.4.0
434
-
435
- # View all changes since a version
436
- aliasmate changelog --from 1.2.0
437
- ```
438
-
439
- **Automatic Upgrade Notifications:**
440
- When you upgrade AliasMate, you'll automatically see:
441
- - Summary of new features and improvements
442
- - Cumulative changes since your last version
443
- - Links to full documentation
444
-
445
- This ensures you never miss important features or fixes when upgrading!
446
-
447
- ### Command Aliases
448
-
449
- Create short aliases for frequently used saved commands:
450
-
451
- ```bash
452
- # Create an alias
453
- aliasmate alias b build
454
- aliasmate alias d deploy-prod
455
-
456
- # List all aliases
457
- aliasmate alias --list
458
-
459
- # Remove an alias
460
- aliasmate alias --remove b
461
- ```
462
-
463
- **Features:**
464
- - Keyboard-friendly shortcuts for long command names
465
- - Validates against reserved command names
466
- - Shows both alias and original command when executing
467
- - Stored separately from commands in metadata
468
-
469
- **Example:**
470
- ```bash
471
- # Create aliases for common commands
472
- aliasmate alias b build
473
- aliasmate alias t test
474
- aliasmate alias dp deploy-prod
475
-
476
- # Use the aliases
477
- aliasmate run b # Runs 'build' command
478
- aliasmate run @0 # Runs most recent command
479
- ```
480
-
481
- ### Recent Commands
482
-
483
- Track and quickly re-run recently executed commands:
484
-
485
- ```bash
486
- # View recent commands
487
- aliasmate recent
488
-
489
- # Limit the list
490
- aliasmate recent --limit 10
491
-
492
- # Clear history
493
- aliasmate recent --clear
494
- ```
495
-
496
- **Quick re-execution with @N syntax:**
497
- ```bash
498
- aliasmate run @0 # Run most recent command
499
- aliasmate run @1 # Run second most recent
500
- aliasmate run @2 # Run third most recent
501
- ```
502
-
503
- **Features:**
504
- - Automatic execution tracking
505
- - Deduplicated display (shows unique commands)
506
- - Shows last run time and execution count
507
- - Configurable history size (default: 50)
508
- - Time-ago formatting (e.g., "2 minutes ago")
509
-
510
- ### Dry-Run Mode
511
-
512
- Preview what will execute before running a command:
513
-
514
- ```bash
515
- # Basic preview
516
- aliasmate run build --dry-run
517
-
518
- # Detailed preview with env vars
519
- aliasmate run build --dry-run --verbose
520
- ```
521
-
522
- **What you'll see:**
523
- - Full command to be executed
524
- - Working directory
525
- - Path mode (saved/current/overridden)
526
- - Environment variables (with sensitive values masked)
527
- - Dangerous command warnings (rm -rf, dd, etc.)
528
-
529
- **Example output:**
530
- ```
531
- 🔍 DRY RUN MODE - Command will NOT be executed
532
-
533
- Command:
534
- npm run build --production
535
-
536
- Working Directory:
537
- /path/to/project
538
-
539
- Path Mode:
540
- saved
541
-
542
- Environment Variables:
543
- 3 variable(s) will be loaded
544
-
545
- NODE_ENV=production
546
- API_URL=https://api.example.com
547
- API_KEY=abc***xyz (masked)
548
-
549
- ⚠️ WARNING: This command may be dangerous
550
-
551
- To execute, run without --dry-run flag
552
- ```
553
-
554
- ### Command Validation
555
-
556
- Validate commands when saving to catch errors early:
557
-
558
- ```bash
559
- # Validate a single command
560
- aliasmate validate build
561
-
562
- # Validate all commands
563
- aliasmate validate --all
564
-
565
- # Skip validation when saving (bypass checks)
566
- aliasmate save --no-validate
567
- aliasmate edit <name> --no-validate
568
- ```
569
-
570
- **What gets validated:**
571
- - **Command existence:** Checks if command is in PATH or is a shell builtin
572
- - **Directory existence:** Verifies directory exists and is accessible
573
- - **Shell syntax:** Basic syntax validation (quotes, brackets, pipes)
574
- - **Environment variables:** Validates variable name patterns
575
-
576
- **Validation types:**
577
- - **Errors:** Block command execution (red)
578
- - Command not found
579
- - Directory doesn't exist
580
- - Invalid syntax
581
-
582
- - **Warnings:** Allow execution with notice (yellow)
583
- - Undefined environment variables
584
- - Non-executable file paths
585
-
586
- **Example:**
587
- ```bash
588
- $ aliasmate validate build
589
-
590
- Validating command: build
591
-
592
- ✓ No issues found
593
- Command: npm run build
594
- Directory: /path/to/project
595
- Environment Variables: 2
596
-
597
- $ aliasmate validate --all
598
-
599
- Validating 15 saved commands...
600
-
601
- ✓ 13 commands passed validation
602
- ⚠ 2 commands have warnings
603
-
604
- Commands with issues:
605
- deploy: Warning - Command 'deploy.sh' not found in PATH
606
- ```
607
-
608
- ### Output Formatting
609
-
610
- Export or view commands in multiple formats:
611
-
612
- ```bash
613
- # List in different formats
614
- aliasmate list --format table # Default human-readable
615
- aliasmate list --format json # Machine-readable JSON
616
- aliasmate list --format yaml # YAML format
617
- aliasmate list --format compact # One-line per command
618
-
619
- # Export with format
620
- aliasmate export commands.json --format json
621
- aliasmate export commands.yaml --format yaml
622
- ```
623
-
624
- **Format examples:**
625
-
626
- **JSON:**
627
- ```json
628
- {
629
- "build": {
630
- "command": "npm run build",
631
- "directory": "/path/to/project",
632
- "pathMode": "saved",
633
- "env": { "NODE_ENV": "production" },
634
- "createdAt": "2026-01-22T10:00:00Z"
635
- }
636
- }
637
- ```
638
-
639
- **YAML:**
640
- ```yaml
641
- build:
642
- command: "npm run build"
643
- directory: "/path/to/project"
644
- pathMode: saved
645
- env:
646
- NODE_ENV: "production"
647
- createdAt: "2026-01-22T10:00:00Z"
648
- ```
649
-
650
- **Compact:**
651
- ```
652
- build: npm run build (/path/to/project)
653
- test: npm test (/path/to/project)
654
- deploy: ./deploy.sh (/path/to/scripts)
655
- ```
656
-
657
- **Use cases:**
658
- - CI/CD integration (JSON/YAML)
659
- - Scripting and automation
660
- - Quick scanning (compact)
661
- - Team sharing with sensitive data masked
662
-
663
- ## Configuration
664
-
665
- Commands are stored in:
666
- - **Linux/macOS**: `~/.config/aliasmate/config.json`
667
- - **Windows**: `%USERPROFILE%\.config\aliasmate\config.json`
668
-
669
- ## Command Reference
670
-
671
- | Command | Aliases | Description |
672
- |---------|---------|-------------|
673
- | `aliasmate prev <name>` | - | Save the previous command from shell history (with optional env vars) |
674
- | `aliasmate run <name> [path]` | - | Run a saved command (restores env vars, optionally override directory) |
675
- | `aliasmate run @N` | - | Run Nth recent command (e.g., @0 = most recent) |
676
- | `aliasmate run <name> --dry-run` | - | Preview command without executing |
677
- | `aliasmate save` | - | Interactively save a new command (with optional env vars) |
678
- | `aliasmate save --no-validate` | - | Save command without validation |
679
- | `aliasmate list` | `ls` | List all saved commands (shows env var indicators) |
680
- | `aliasmate list --format <type>` | - | List in different formats (table/json/yaml/compact) |
681
- | `aliasmate search <query>` | `find` | Search for commands by name, text, or directory |
682
- | `aliasmate edit <name>` | - | Edit a saved command (manage env vars, path mode, etc.) |
683
- | `aliasmate edit <name> --no-validate` | - | Edit command without validation |
684
- | `aliasmate delete <name>` | `rm` | Delete a saved command |
685
- | `aliasmate export <file>` | - | Export commands to a file (sensitive vars masked) |
686
- | `aliasmate export <file> --format <type>` | - | Export in JSON or YAML format |
687
- | `aliasmate import <file>` | - | Import commands from a file (auto backup) |
688
- | `aliasmate alias <short> <command>` | - | Create alias for a command |
689
- | `aliasmate alias --list` | - | List all aliases |
690
- | `aliasmate alias --remove <alias>` | - | Remove an alias |
691
- | `aliasmate recent` | - | Show recently executed commands |
692
- | `aliasmate recent --limit <N>` | - | Limit recent commands displayed |
693
- | `aliasmate recent --clear` | - | Clear execution history |
694
- | `aliasmate validate <name>` | - | Validate a single command |
695
- | `aliasmate validate --all` | - | Validate all saved commands |
696
- | `aliasmate completion <shell>` | - | Generate shell completion script (bash, zsh, fish) |
697
- | `aliasmate changelog` | `changes` | View version changelog and release notes |
698
- | `aliasmate config` | - | Show config file location and command count |
699
-
700
- ## Examples
701
-
702
- ### Common Workflows
703
-
704
- **1. Save and reuse a build command:**
705
- ```bash
706
- cd /my/project
707
- npm run build -- --production
708
- aliasmate prev build-prod
709
- # Later, from anywhere:
710
- aliasmate run build-prod
711
- ```
712
-
713
- **2. Save a deployment script:**
714
- ```bash
715
- aliasmate save
716
- # Name: deploy
717
- # Command: ./scripts/deploy.sh --env production
718
- # Directory: /path/to/project
719
- ```
720
-
721
- **3. Run a command in a different directory:**
722
- ```bash
723
- aliasmate run test /path/to/different/project
724
- ```
725
-
726
- **4. Backup your commands:**
727
- ```bash
728
- aliasmate export ~/backups/aliasmate-$(date +%Y%m%d).json
729
- ```
730
-
731
- **5. Share commands with your team:**
732
- ```bash
733
- # Person A
734
- aliasmate export team-commands.json
735
-
736
- # Person B
737
- aliasmate import team-commands.json
738
- ```
739
-
740
- ## Tips
741
-
742
- - Use descriptive names for your commands (e.g., `build-prod`, `test-unit`, `deploy-staging`)
743
- - Regularly export your commands as backup
744
- - The `prev` command is great for saving complex commands you just figured out
745
- - Use path override to run the same command in multiple projects
746
-
747
- ## Troubleshooting
748
-
749
- ### "Could not retrieve previous command from history"
750
-
751
- This happens when shell history is disabled or the command hasn't been written to the history file yet.
752
-
753
- **Common scenario**: You run a command, press `^C` to cancel it, and immediately run `aliasmate prev`, but it captures an older command (like `clear`) instead.
754
-
755
- **Why**: Most shells only write to history when the shell exits, not after each command.
756
-
757
- **Solution**: Configure real-time history writing (see [Shell Configuration](#shell-configuration-recommended) above):
758
- - **zsh**: Add `setopt INC_APPEND_HISTORY` to `~/.zshrc`
759
- - **bash**: Add `PROMPT_COMMAND="history -a"` to `~/.bashrc`
760
-
761
- **Quick fix**: Close and reopen your terminal, then try the command again.
762
-
763
- **Alternative**: Use `aliasmate save` to enter commands manually.
764
-
765
- ### Commands not executing properly
766
-
767
- - Verify the saved directory exists: `aliasmate list`
768
- - Check if the command requires environment variables or specific shell configuration
769
- - Try running the command manually in the saved directory first
770
-
771
- ### History file not found
772
-
773
- Make sure your shell history is enabled:
774
- - Check for `~/.zsh_history` (zsh) or `~/.bash_history` (bash)
775
- - If missing, history may be disabled - check your shell configuration files
93
+ The format is unchanged from AliasMate 1.x — upgrading keeps all your commands.
776
94
 
777
95
  ## Development
778
96
 
779
- To work on AliasMate locally:
780
-
781
97
  ```bash
782
- # Clone the repository
783
- git clone https://github.com/aliasmate/aliasmate.git
784
- cd aliasmate
785
-
786
- # Install dependencies
787
98
  npm install
788
-
789
- # Build the project
790
- npm run build
791
-
792
- # Run type checking
793
- npm run typecheck
794
-
795
- # Lint the code
796
- npm run lint
797
-
798
- # Format code
799
- npm run format
800
-
801
- # Link for local testing
802
- npm link
803
-
804
- # Test the CLI
805
- aliasmate --help
99
+ npm run build # compile TypeScript
100
+ npm test # run the test suite
101
+ npm run lint # ESLint
102
+ npm run format # Prettier
103
+ npm link # try the CLI locally
806
104
  ```
807
105
 
808
- ### Development Scripts
809
-
810
- | Script | Description |
811
- |--------|-------------|
812
- | `npm run build` | Compile TypeScript to JavaScript |
813
- | `npm run dev` | Watch mode for development |
814
- | `npm run typecheck` | Run TypeScript type checking |
815
- | `npm run lint` | Check code quality with ESLint |
816
- | `npm run lint:fix` | Auto-fix ESLint issues |
817
- | `npm run format` | Format code with Prettier |
818
- | `npm run format:check` | Check if code is formatted |
819
-
820
- ### Code Quality
821
-
822
- AliasMate is built with modern development practices:
823
-
824
- - ✅ **TypeScript** with strict mode enabled
825
- - ✅ **ESLint** for code quality enforcement
826
- - ✅ **Prettier** for consistent formatting
827
- - ✅ **Comprehensive JSDoc** documentation
828
- - ✅ **Centralized error handling** with proper exit codes
829
- - ✅ **Zero type safety warnings** in production code
830
-
831
- For detailed contribution guidelines, see [CONTRIBUTING.md](./CONTRIBUTING.md).
832
-
833
- ## Project Structure
834
-
835
- ```
836
- aliasmate/
837
- ├── src/
838
- │ ├── cli.ts # CLI entry point
839
- │ ├── commands/ # Command implementations
840
- │ │ ├── prev.ts # Save from history
841
- │ │ ├── run.ts # Execute commands
842
- │ │ ├── save.ts # Interactive save
843
- │ │ ├── list.ts # Display all
844
- │ │ ├── edit.ts # Modify commands
845
- │ │ ├── delete.ts # Remove commands
846
- │ │ ├── export.ts # Backup to JSON
847
- │ │ └── import.ts # Restore from JSON
848
- │ ├── storage/
849
- │ │ └── index.ts # Config persistence
850
- │ └── utils/
851
- │ ├── constants.ts # Shared constants
852
- │ ├── errors.ts # Error handling
853
- │ ├── executor.ts # Command execution
854
- │ ├── history.ts # Shell integration
855
- │ └── paths.ts # Path utilities
856
- ├── dist/ # Compiled output
857
- └── docs/
858
- ├── CONTRIBUTING.md # Contributor guide
859
- ├── DEV_GUIDE.md # Quick reference
860
- └── CLEANUP_SUMMARY.md # Code quality report
861
- ```
106
+ Architecture: `src/core/` is pure domain logic (storage, resolution, validation, execution) with no UI dependencies; `src/ui/` handles theming, formatting, and prompts; `src/cli/` contains thin command handlers that are lazy-loaded so startup stays fast (~30 ms).
862
107
 
863
108
  ## License
864
109
 
865
110
  MIT
866
-
867
- ## Contributing
868
-
869
- Contributions are welcome! We appreciate:
870
-
871
- - 🐛 Bug reports and fixes
872
- - ✨ Feature suggestions and implementations
873
- - 📝 Documentation improvements
874
-
875
- **Maintainer**: AliasMate Contributors
876
-
877
- ## Changelog
878
-
879
- See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
880
-
881
- ## Support
882
-
883
- - 📖 [Documentation](./README.md)
884
- - 🐛 [Issue Tracker](https://github.com/aliasmate/aliasmate/issues)
885
- - 💬 [Discussions](https://github.com/aliasmate/aliasmate/discussions)
886
-
887
- ---
888
-
889
- **⭐ If you find AliasMate helpful, please consider giving it a star on GitHub!**
890
- - 🎨 Code quality enhancements
891
-
892
- Before contributing, please:
893
-
894
- 1. Read our [Contributing Guide](./CONTRIBUTING.md)
895
- 2. Check existing issues and pull requests
896
- 3. Follow the code style (ESLint + Prettier)
897
- 4. Add tests for new features (when applicable)
898
- 5. Update documentation as needed
899
-
900
- ### Quick Start for Contributors
901
-
902
- ```bash
903
- # Fork and clone the repository
904
- git clone https://github.com/YOUR_USERNAME/aliasmate.git
905
- cd aliasmate
906
-
907
- # Install dependencies
908
- npm install
909
-
910
- # Make your changes, then:
911
- npm run format # Format code
912
- npm run lint # Check for issues
913
- npm run typecheck # Verify types
914
- npm run build # Build project
915
-
916
- # Test locally
917
- npm link
918
- aliasmate --help
919
- ```
920
-
921
- See [DEV_GUIDE.md](./DEV_GUIDE.md) for detailed development workflows.
922
-
923
- ## Author
924
-
925
- Created with ❤️ for developers who love productivity tools.