-
Notifications
You must be signed in to change notification settings - Fork 133
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
rl.expandtilde does not expand tilde #326
Comments
Ugh. The problem is that Readline's logic for expanding tilde is overly simplistic, and it wrongly expands some inputs. Fixing that has introduced the opposite problem where now it doesn't expand all tildes in an entire command line that's passed in at once. Basically, there will need to be two different modes for the function:
Replacing all tildes with |
As you can see in the documentation for rl.expandtilde(), the function is intended to be used with a single pathname as the input. When used according to the documentation (such as in match generators), it is incorrect for the function to behave the way you expected it to. But the old behavior can still be useful in some special cases, so I'm adding a second argument to the function to request the old behavior. In v1.3.37 and higher, passing (P.S. I am tickled that I can tag this issue with both "bug" and "working as intended" labels. 🤣) |
Thanks for looking into this, I'll be very glad to see this functionality returned! Definitely streamlines my shell experience. |
Adds an optional argument to rl.expandtilde to indicate that the input is a whole command line, to request Readline's quirky tilde expansion to be used and expand all tildes that are preceded immediately by a space (or at the beginning of the input). When the second argument is false or is omitted, then the function behaves how it was always documented to behave (though its behavior didn't match the documentation until v1.3.36).
This new behavior is available in v1.3.37 now. You can update the following line in HomeClink.lua from this: local expanded_input, was_expanded = rl.expandtilde(escaped_input) To this: local expanded_input, was_expanded = rl.expandtilde(escaped_input, true) |
That's fixed it :) Thank you for all your hard work on the project! As an aside, is there any active repo where we can submit clink completions? |
clink-gizmos could be a good place, depending on what the script is. |
I was thinking specifically of CheatCompletions, but realistically it'd be ideal to have a go-to official repo for clink extensions that people could submit to via PR, in this way you don't have to comb Github via search for an extension you want, and it makes it less likely people will spend time making extensions for the same thing (for example, I think I've seen at least 4 different implementations of a |
Well, what does it mean to have an official repo for all Clink extensions? Should everyone load 1000 extensions if they only use 10 of them? It's easy to make a quick and dirty hack that's good enough for my own needs, and push it into a repo where everyone else is forced to use it. That's what I'm trying to do with clink-gizmos. What you're looking for is not a repo, really. You're looking for a catalog, where you can find things and choose whether to use them. Git repos aren't well suited to that role. Anyway, as I've mentioned in other posts on this topic, I already invest a large amount of time into programming Clink. I'm not going to also build a catalog web site. Someone else is welcome to do so, of course. |
The one in clink-completions is pretty good. Especially the PR that is pending. But Vladimir seems to have abandoned it, so I may have to promote my fork as the new active repo. |
I've been using HomeClink to approximate automatic tilde expansion and allow commands like
cd ~
to cd to the user's home directory.Unfortunately upon updating to the latest clink version,
rl.expandtilde()
is no longer expanding the tilde in this expression. For example, when I print the result ofrl.expandtilde('cd ~')
, the result iscd ~
and expanded isfalse
. This has been happening since I upgraded fromv1.3.17
tov1.3.36
.Is there any way to restore the functionality of
rl.expandtilde()
? I could just change the functionality of HomeClink to manually replace~
with%HOME%
, but I just wanted to make sure this wasn't a bug first.The text was updated successfully, but these errors were encountered: