2do2go/nrun

Find script to run by partial text match

bahmutov opened this issue · 4 comments

I am tired of typing the entire command. What if nrun i could find the only script command that matches and runs "issues": "git-issues" for example?

okv commented

Do you mean to dynamically find matched script by name?
If so, we do not do that because we think shell completion (nrun --completion >> ~/.bashrc) is good way to reach shorter commands.

Not sure this is a good solution. Not cross platform, or even cross shell. Not tested, and the shell syntax is a minefield of the future.

okv commented

Shell completion is not ideal (because of it's not cross platform nature in general) but worked for years =) It's pretty standard way for posix systems.
Imo, bad thing about dynamically partial commands matching is that it's not consistent over time and projects (e.g. nrun i may run one command today and another tomorrow (after changing package.json) or it will run different commands in different projects).
You can also use shell aliases or package.json for permanent short commands.

I wrote my own https://github.com/bahmutov/npm-quick-run that does the completion in code, seems to work for my needs.