I was just typing something along the lines of:
mv foo/bar/poit/zoid/narf.txt
and suddenly realized, damn, I have to type large parts of that parameter again
mv foo/bar/poit/zoid/narf.txt foo/bar/poit/zoid/troz.txt
Even with tabcompletion, quite a pain. I know I can copy paste the parameter by mouse-selecting the text and middleclick but that is not good enough. I want to remain on the keyboard.
So is there a way to copy paste the current parameter of the line using the keyboard?
Best Answer
If I've planned ahead, I use brace expansion. In this case:
Here is another approach using the default
readline
keyboard shortcuts:mv foo/bar/poit/soid/narf.txt
: startunix-word-rubout
to deletefoo/bar/poit/soid/narf.txt
yank
, space,yank
again to getmv foo/bar/poit/soid/narf.txt foo/bar/poit/soid/narf.txt
backward-kill-word
twice to delete the lastnarf.txt
troz.txt
: type the tail part that is differentIf you spend any non-trivial amount of time using the
bash
shell, I'd recommend periodically reading through a list of the default shortcuts and picking out a few that seem useful to learn and incorporate into your routine. Chapter 8 of thebash
manual is a good place to start. Knowing the shortcuts can really raise your efficiency.