Bug 13611

Summary: Please add M-. (yank-last-arg) to busybox sh (libbb/libedit.c)
Product: Busybox Reporter: Trent W. Buck <trentbuck+busybox-sold-my-email-address>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: enhancement CC: busybox-cvs, trentbuck+busybox-sold-my-email-address
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

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.