-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
meta+period should insert last argument of previous command #89
Comments
@jab, from one bash user to another -- I accidentally discovered that you can get what you want by simply typing out (possibly with tab-completion) the command, adding a space and then pressing the up-down arrow to scroll thru' the previous command's argument list. Pretty cool stuff ! I agree, fish is awesome. |
thanks @lonetwin, but that doesn't seem to be working for me. for me pressing up only shows completions from previous commands matching what i've typed so far (everything to the left of the cursor). So if I have:
And I see a file in there "foo" I want to edit, in bash I could just type "vim ", then meta+period to insert that long path, and then just add "foo". But in fish, typing "vim " and then hitting up does not complete from the previous command, since "vim " does not match "ls". (Incidentally, I always use Ctrl+P instead of up arrow and Ctrl+N instead of down in order to avoid taking my hands away from the home row.) |
+1 to this, I miss it sorely too. |
+1 for this! missing it too |
+1 |
I see this has been marked for fish-future, but seems to have substantial user interest. Would this be hard to add? If someone from the community wanted to take a crack at it, would a good patch be accepted? Any pointers on how to do it for someone who hasn't looked at the code before? |
The following binding will do what you're looking for, though it breaks if the first character is a hyphen. Maybe someone can help with that?
|
should fix that problem with the dash. But it's notably missing:
|
Close! I had to move the -- outside of the parens. (advice from maxfl at Issue 140)
This fixes the problem with the dash, but it turns out I was solving the wrong problem. :) This inserts ALL arguments from the previous command, not the last one. All these years of bash/zsh and I was never aware of this feature. I'll take another stab at it when I have the chance. Thanks for the advice. |
Thanks for sharing your progress on a DIY version, @mikewho and @gfxmonk. Look forward to trying once you get a chance to take another stab at it. Being able to cycle through the last arguments of multiple previous commands by continuing to hit period would be awesome, but even just being able to get the most recent command's could go a long way. Of course, I'm also still hoping the fish core developers will notice this ticket and provide built-in support. You there, guys? |
Agreed, for the reasons I pointed out above I don't think the script based |
I think it's tricky, but possible for a script based solution. |
If anyone could point me towards the right .cpp file, I could give it a try. I just haven't found the time yet to read through enough of the code to understand how things work together :-/ |
Hi, have you tried AltUp/AltDown keys? This feature comes from the original fish, but was broken in the first beta. Now it works. |
Ahh excellent - that works great @maxfl. Especially paired with |
history-token-search-backward suits me, but is there still a demand for a yank-last-arg script? I'm halfway through coding it. |
Yes please! |
Cool. I'll keep at it. It's kind of fun working within the limitations of what's available. Just curious.. what use cases do you find yank-last-arg an advantage over history-token-search-backward? |
I want to do something like:
all the time, but I don't see how history-token-search-backward helps with that. Am I missing something? |
history-token-search-backward would do the same thing in that case. Where it differs is that if you pressed Alt+. again, the next token would be "ls", not the last argument of the command prior to "ls path/to/deeply/nested/directory". |
When I press Alt+. in the context above, nothing happens. |
I'm using OS X with iTerm2 using "Option key acts as +Esc". There could be a few issues. history-token-search-backward only started working a week or two ago for me, so definitely try compiling from the latest source. I know the OS X Installer is a little behind. Also, by default history-token-search-backward is bound to Alt-Up. Maybe give that a shot. |
Ah, that was it. I had been running from the .pkg installed version from http://ridiculousfish.com/shell/beta.html. Built my own from latest git master and history-token-search-backward (with the \e. binding) is working like a charm. Thanks @mikewho! |
Hi, I am coming from BASH and this (atl+. even repeated several times) is one of most used features for me, it would be great to have that in fish. ls -l update.conf |
function fish_user_keybindings in .config/fish/config.fish makes M-. available for me on recent fish. it does cycle through all parameters, not only the last, but I'd consider that a feature :) |
The function name has since changed from
|
I believe the issue has been resolved here. Can it be closed now? |
@mrshu I understood the issue was about making this part of fish by default, rather than requiring writing your own keybindings. So I wouldn't consider it closed until that's done (or else it's declared that it won't be part of fish). |
ping @ridiculousfish, any interest in making this the default behavior? |
I don't have any objection. |
hooray! |
First of all, thanks for fish, it's totally awesome.
I just switched from bash, and the thing I'm acutely missing is meta+period to insert the last argument of the previous command. I've tried in both Terminal and iTerm 2, both of which I have configured to send +Esc for the left option key, but when I hit option+period, it just prints the period. Some way to make this work?
The text was updated successfully, but these errors were encountered: