0

Is there some way to get the actual expanded contents of a command-line that I ran recently? By this I mean the literal "argv", not the text before parameter expansion and similar steps.

In my case, I'm using zsh, but I'd be interested if there's any support for this in any combination of shell and terminal emulator.

Inspiration for this question was fat-fingered use of fzf.

2 Answers 2

0

zsh-autosuggestions is exactly what you're looking for.

1
  • Please describe how this answers the question. … … … … … … … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete. Commented Oct 9, 2020 at 22:03
0

I'm not sure how to expand a command that has already entered the history, but I wrote a function to select any files through fzf and have them passed to whatever program (GUI or command line tool) you want (you can also see it in an answer on stackoverflow). And I made it so that when you cycle back through your history and find the command as it was expanded after fzf did its thing. I use it many times a day, mainly to change directory or open files.

I called the function 'f', so if you wanted to cat a file with line numbers (-b) and newline symbols (-E) you would do:

f cat -bE

or

f cat -b -E

and hit enter. FZF launches and whatever file(s) you choose would be passed as arguments.

Then when you went back in your command history, you'd see:

cat -bE '/home/mattb/todo/README.md'

instead of:

f cat -bE

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .