Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab completion should not expand ~ or variable #474

Open
xiaq opened this issue Aug 27, 2017 · 5 comments
Open

Tab completion should not expand ~ or variable #474

xiaq opened this issue Aug 27, 2017 · 5 comments
Labels

Comments

@xiaq
Copy link
Member

xiaq commented Aug 27, 2017

Typing echo ~/<Tab> will expand the home directory; this is not desirable.

@mqudsi
Copy link

mqudsi commented Aug 27, 2017

Thank you. I considered it a bug for myself, but presumed it was intentional.

@krader1961
Copy link
Contributor

There was a recent question about this behavior on the chat channels. My reply to that question is below....

I never use Tab completion when the path includes a leading tilde so I've never been bothered by this. That's because I only do cd ~/someplace when the path is very short; e.g., cd ~ or cd ~/log. Pretty much for anything else I use location mode since I've usually already navigated to the directory and it's in my location history. Still, I agree that path completion shouldn't substitute the actual home dir for the tilde. However, I think variables should be expanded by Tab completion. If you don't want the command history to reflect the actual value at the time the command was executed then don't use Tab completion. If you do type something like cd ${A-var}/subdir followed by Tab then I would expect the variable to be expanded.

@krader1961
Copy link
Contributor

Note that expansion of a leading tilde by Tab completion is counterproductive given that user home directories almost never change. Expansion by Tab completion replaces a single character with many characters that are unlikely to change and thus has close to zero value. It is preferable to leave the expansion of the leading tilde to the code that interprets the path.

@haxscramper
Copy link

Additionally, expanding tilde makes it harder to copy-paste things from the history to documentation, for sending code to the others as example. This is more of a niche case and this functionality can be made into opt-out instead of changing the default behavior.

@krader1961
Copy link
Contributor

krader1961 commented Dec 25, 2023

This is more of a niche case and this functionality can be made into opt-out instead of changing the default behavior.

While backward incompatible changes should be avoided this is one case where I think doing so is acceptable. Because (a) it only affects interactive use and thus won't break any existing Elvish code, and (b) I'm confident that most Elvish users will prefer the new, non-tilde expansion, Tab completion behavior.

It's just a small matter of someone modifying the existing code to provide the non-expansion behavior. Which is obviously not serious (i.e., sarcastic) since a change of this nature is complicated and thus not a "small matter".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants