Bug 13611 - Please add M-. (yank-last-arg) to busybox sh (libbb/libedit.c)
Summary: Please add M-. (yank-last-arg) to busybox sh (libbb/libedit.c)
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 enhancement
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-11 09:45 UTC by Trent W. Buck
Modified: 2021-03-11 09:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Trent W. Buck 2021-03-11 09:45:20 UTC
In readline (bash, python, cmucl, mysql, &c) as well as ^P (Ctrl+P) changing the input line to the previous command, there is also M-. (Alt+.) to insert the last argument of the previous command.

This is super handy for cases like this:

  ls foo
  ls foo/bar
  ls foo/bar/*.txt
  rm -rf foo/bar/*.txt

In each of those cases, you can type M-. to avoid typing the path out.
When the path is very long, this avoids having to spam "cd" or do a lot of left/right/backspace editing.

I had a quick look and it looks like this would be a variant of libbb/libedit.c:get_previous_history.

My C-fu isn't quite up to actually creating a proof-of-concept patch, sorry.


PS: in libreadline you can also do M-3 M-. to insert the third-last argument (e.g. "echo foo bar baz RET M-3 M-." would insert "foo").
You can also type M-. repeatedly to go back further in history, like C-p (e.g. "echo x RET echo y RET M-. M-." would insert "x").
These extras are nice-to-have but not nearly as useful as M-. alone.