In editors like vim
and emacs
, one can use hotkeys like C-p
(vim) or M-/
(emacs) to perform auto-completion on the current word using other words in the same buffer.
Is it possible to achieve the same functionality within a shell? If I see some word in output from a previous command and I'd like to quickly auto-complete it when typing out another command.
Just to be clear, an example:
$ ls
Desktop/ Mail/ music/ osx@ something_with_a_pretty_long_name
$ someth
From here, I'd like to be able to hit a hotkey and have it automatically complete what I'm typing to something_with_a_pretty_long_name
.
EDIT: Shoot. Using a filename was a poor example for what I'm after. Consider the following, second example:
$ cat /var/log/something.log
[19:30] Service started
[19:35] Something else happened
$ happ
Where I could auto-complete 'happ' to 'happened' merely because it appeared in my terminal buffer. I hope this clarifies what I'm after.
M-X shell
)?M-/
works as always, and <kbd>Tab</kbd> works for just filenames/commands.shell
, but it tends to annoy me too much to use for protracted lengths of time. Emacs of course implements this at the terminal level, and that's probably where you'd want to look for it. And I fear you'd need a patch. I haven't seen a mainstream (or niche) terminal provide this functionality.