3 ms·
Well, an argument could be made for having the alias-file be something like: alias ll="ls -l" doc = """List files -- long list format""" natura
by e12e 13y ago
Well, an argument could be made for having the alias-file be something like:
alias ll="ls -l"
doc = """List files -- long list format"""
natural_match = "list all files long size date owner group"
And have:
"list all files by size"
match this (as betty does now: running ll "docstring". Then, when you
realize that "list all files by size", really is "ls --sort=size",
possibly with "-l", you could just add another definition:
alias lss="ls -l --sort=size"
doc = """List files -- sorted by size, long list format"""
natural_match = "list all files sort by size long format"
natural_exact_match "list all files by size"
And now have:
"list all files by size"
Score higher for lss than for ll (the scoring function is assumed to be
some combination of tag count, proximit match, substring match etc, a
so-called hard problem, but only needs to match over defined aliases --
and trying hard to first match the "exact_match" part...).
Of course, it should all be paired by a define-command or something that
autmatically saves these monstrosties to a file or other db. So that you
could do:
# Lots of head scratching and experimentation, until:
nmcli dev wifi list |sort -k8 -n # list wifi access points by
# signal strength
# define prev as "list wifi access points by signal strength"
> displays commmand and prompt for tags etc, then on "y" at y/n
prompt saves definition to "alias" file.
Come to think of it, it's a little like mandating/recommending users to
document their aliases, and to have the shell automatically suggest
from the docstrings. I guess zsh actually does a bit of this already
(I'm still sticking with bash, it's gotten good enough for me over the
years, and I'm always terrified by something, that if it isn't posix/ksh
also isn't bash -- as that just makes scripts brittle...).