GiselleSerate / myaliases

Useful shell aliases and functions.
6 stars 1 forks source link

cds tab completion with multiple shortcuts and "cds -" #30

Closed aryarm closed 6 years ago

aryarm commented 6 years ago

You can pass more than one shortcut name to cds - to delete multiple shortcuts at a time (ex: cds - <shortcut1> <shortcut2>.

When tab completing cds -, only the first shortcut gets completions. _cds is not prepared to handle tab completions for cds - with an arbitrary number of shortcuts to be deleted. So completions for cds - <letter(s)>[tab] works but those for cds - <shortcut1> <letter(s)>[tab] and cds - <shortcut1> <shortcut2> <letter(s)>[tab] do not work.

Also, completions should work at any point in typing the command, so cds - <letter(s)>[tab] <shortcut2> should also work.

aryarm commented 6 years ago

Plans

aryarm commented 6 years ago

Turns out that removing shortcut names that have already been typed from the completions is harder than I thought, especially because bash doesn't have an elegant way of checking whether an element exists in an array. My final attempt was on commit a4d27f6bfc94fa4593c0757da4e40d960ca8f3c4 but then I gave up and put everything back to normal in commit cc444c29f4c455d708af3e9a9d18e9aefd458ecf. I might come back to this later, but it seems like code for _cds will be significantly more simple if this feature isn't implemented.