@tnqai/alim 1.1.0 → 1.2.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.
- package/alias-manager.js +47 -16
- package/package.json +1 -1
package/alias-manager.js
CHANGED
|
@@ -187,6 +187,26 @@ const commands = {
|
|
|
187
187
|
process.exit(1);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
// Check if shell wrapper function exists
|
|
191
|
+
const shellConfig = getShellConfig();
|
|
192
|
+
if (fs.existsSync(shellConfig)) {
|
|
193
|
+
const content = fs.readFileSync(shellConfig, 'utf8');
|
|
194
|
+
if (!content.includes('alm() {') && !content.includes('function alm')) {
|
|
195
|
+
console.log('⚠️ Shell wrapper function not found!\n');
|
|
196
|
+
console.log('To make addx work automatically, add this function to your shell:\n');
|
|
197
|
+
console.log('alm() {');
|
|
198
|
+
console.log(' if [ "$1" = "addx" ]; then');
|
|
199
|
+
console.log(' command alm "$@" && source ' + shellConfig);
|
|
200
|
+
console.log(' else');
|
|
201
|
+
console.log(' command alm "$@"');
|
|
202
|
+
console.log(' fi');
|
|
203
|
+
console.log('}\n');
|
|
204
|
+
console.log('💡 Quick install:');
|
|
205
|
+
console.log(' alm install-wrapper\n');
|
|
206
|
+
process.exit(1);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
190
210
|
// Check if alias already exists
|
|
191
211
|
const existing = loadAllAliases().find(a => a.name === name);
|
|
192
212
|
if (existing) {
|
|
@@ -198,26 +218,35 @@ const commands = {
|
|
|
198
218
|
ensureShellConfig();
|
|
199
219
|
|
|
200
220
|
console.log(`✅ Added alias: ${name} → ${command} [${category}]`);
|
|
201
|
-
console.log(
|
|
202
|
-
console.log(` eval "$(alm addx-eval ${name})"`);
|
|
203
|
-
console.log(`\nOr source your shell config:`);
|
|
204
|
-
console.log(` source ${getShellConfig()}`);
|
|
221
|
+
console.log(`✅ Alias will be loaded automatically (via shell wrapper)`);
|
|
205
222
|
},
|
|
206
223
|
|
|
207
|
-
'
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
224
|
+
'install-wrapper'() {
|
|
225
|
+
const shellConfig = getShellConfig();
|
|
226
|
+
|
|
227
|
+
if (fs.existsSync(shellConfig)) {
|
|
228
|
+
const content = fs.readFileSync(shellConfig, 'utf8');
|
|
229
|
+
if (content.includes('alm() {') || content.includes('function alm')) {
|
|
230
|
+
console.log('✅ Shell wrapper function already installed');
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
211
233
|
}
|
|
212
234
|
|
|
213
|
-
const
|
|
214
|
-
|
|
235
|
+
const wrapperFunction = `
|
|
236
|
+
# Alias Manager wrapper function
|
|
237
|
+
alm() {
|
|
238
|
+
if [ "$1" = "addx" ]; then
|
|
239
|
+
command alm "$@" && source ${shellConfig}
|
|
240
|
+
else
|
|
241
|
+
command alm "$@"
|
|
242
|
+
fi
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
215
245
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
246
|
+
fs.appendFileSync(shellConfig, wrapperFunction);
|
|
247
|
+
console.log(`✅ Shell wrapper function installed to ${shellConfig}`);
|
|
248
|
+
console.log(`\nRun: source ${shellConfig}`);
|
|
249
|
+
console.log('Now you can use: alm addx <name> <command> [category]');
|
|
221
250
|
},
|
|
222
251
|
|
|
223
252
|
remove(args) {
|
|
@@ -290,11 +319,12 @@ Commands:
|
|
|
290
319
|
list [category] List all aliases (or by category)
|
|
291
320
|
find <keyword> Search aliases
|
|
292
321
|
add <name> <cmd> [cat] Add new alias
|
|
293
|
-
addx <name> <cmd> [cat] Add new alias and auto-load it
|
|
322
|
+
addx <name> <cmd> [cat] Add new alias and auto-load it (requires wrapper)
|
|
294
323
|
remove <name> Remove alias
|
|
295
324
|
categories Show all categories
|
|
296
325
|
export [file] Export aliases to JSON
|
|
297
326
|
import <file> Import aliases from JSON
|
|
327
|
+
install-wrapper Install shell wrapper function for addx
|
|
298
328
|
help Show this help
|
|
299
329
|
|
|
300
330
|
Categories: ${CATEGORIES.join(', ')}
|
|
@@ -304,6 +334,7 @@ Examples:
|
|
|
304
334
|
alias-manager list git
|
|
305
335
|
alias-manager find push
|
|
306
336
|
alias-manager add gp "git push" git
|
|
337
|
+
alias-manager install-wrapper
|
|
307
338
|
alias-manager addx gst "git status" git
|
|
308
339
|
alias-manager remove gp
|
|
309
340
|
alias-manager export backup.json
|