Elvish binding for filtered directory history
xiaq opened this issue · comments
Pedro on the Telegram channel raised the question of whether directory history can be used via an alternative CLI interface - for example, jump-to foo
would be the equivalent of typing Ctrl-L, filter by foo
and going to the first result.
I think the interactivity of location mode makes it more powerful, but on the other hand in the spirit of programmability it should be trivial for a user to implement a jump-to
command if they prefer.
Right now store:dirs
exposes directory history, but the filtering functionality is not exposed. It'd make sense to implement, say edit:location:filter-dirs $filter
to return filtered directory history.
The jump-to
command could then be implemented like:
fn jump-to {|filter| cd (edit:location:filtered-dirs $filter | take 1)}
Should this mimic store:prev-cmd
and store:next-cmd
where the value is a prefix to be matched? If not, why not? Should those commands have the ability for more powerful matching? Also, I don't think this should be exposed by a hypothetical edit:location:filtered-dirs
command. It should be exposed by the store
module.