@tnqai/alim 1.0.0 → 1.1.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 (2) hide show
  1. package/alias-manager.js +49 -0
  2. package/package.json +1 -1
package/alias-manager.js CHANGED
@@ -173,6 +173,53 @@ const commands = {
173
173
  console.log(`\nRun: source ${getShellConfig()}`);
174
174
  },
175
175
 
176
+ addx(args) {
177
+ const [name, command, category = 'misc'] = args;
178
+
179
+ if (!name || !command) {
180
+ console.error('Usage: alias-manager addx <name> <command> [category]');
181
+ console.error('Categories:', CATEGORIES.join(', '));
182
+ process.exit(1);
183
+ }
184
+
185
+ if (!CATEGORIES.includes(category)) {
186
+ console.error(`Invalid category. Choose from: ${CATEGORIES.join(', ')}`);
187
+ process.exit(1);
188
+ }
189
+
190
+ // Check if alias already exists
191
+ const existing = loadAllAliases().find(a => a.name === name);
192
+ if (existing) {
193
+ console.error(`Alias "${name}" already exists in category "${existing.category}"`);
194
+ process.exit(1);
195
+ }
196
+
197
+ saveAlias(name, command, category);
198
+ ensureShellConfig();
199
+
200
+ console.log(`✅ Added alias: ${name} → ${command} [${category}]`);
201
+ console.log(`\n💡 To use immediately, run:`);
202
+ console.log(` eval "$(alm addx-eval ${name})"`);
203
+ console.log(`\nOr source your shell config:`);
204
+ console.log(` source ${getShellConfig()}`);
205
+ },
206
+
207
+ 'addx-eval'(args) {
208
+ const name = args[0];
209
+ if (!name) {
210
+ process.exit(1);
211
+ }
212
+
213
+ const aliases = loadAllAliases();
214
+ const alias = aliases.find(a => a.name === name);
215
+
216
+ if (alias) {
217
+ // Escape single quotes in command
218
+ const escapedCommand = alias.command.replace(/'/g, "'\\''");
219
+ console.log(`alias ${alias.name}='${escapedCommand}'`);
220
+ }
221
+ },
222
+
176
223
  remove(args) {
177
224
  const name = args[0];
178
225
  if (!name) {
@@ -243,6 +290,7 @@ Commands:
243
290
  list [category] List all aliases (or by category)
244
291
  find <keyword> Search aliases
245
292
  add <name> <cmd> [cat] Add new alias
293
+ addx <name> <cmd> [cat] Add new alias and auto-load it
246
294
  remove <name> Remove alias
247
295
  categories Show all categories
248
296
  export [file] Export aliases to JSON
@@ -256,6 +304,7 @@ Examples:
256
304
  alias-manager list git
257
305
  alias-manager find push
258
306
  alias-manager add gp "git push" git
307
+ alias-manager addx gst "git status" git
259
308
  alias-manager remove gp
260
309
  alias-manager export backup.json
261
310
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tnqai/alim",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A simple and elegant alias manager for your shell",
5
5
  "main": "alias-manager.js",
6
6
  "bin": {