I found out that there is currently no readline function (bash uses the readline library for command line editing) to repeat the previous argument. However, I did solve the problem:
As a general solution, for any shell that supports brace expansion, you can use this trick (note that csh, tcsh, bash and pdksh support brace expansion, whereas sh and ksh do not):
mv /var/www/conf/httpd.conf{,.bak}
I.e., the first element in the brace is simply empty. This trick does what we want, but the arguments will not be visible as two separate arguments on the command line, but will be separated (as mv /var/www/conf/httpd.conf /var/www/conf/httpd.conf.bak) when the command is actually executed.
If you actually want an editing command that will repeat the previous argument on the command line, you have to create a macro.
If you use
pdksh in emacs mode, you can put the following line in its ENV config file:
bind -m '^[w=^[b^[^] ^k^y^y'
(Note there are spaces in here.) This creates a macro bound to Meta-w (Alt-w).
If you use
bash in emacs mode (or use any other readline-enabled program), then create a file ~/.inputrc, and put the following line there:
Meta-w: "\C-w\C-y\ \C-y"
(Note there is a space b/w two slashes here.) This creates a macro bound to M-w (Alt-w) that cuts/kills the previous non-whitespace string (C-w), and then pastes/yanks (C-y) it two times, putting a space in between. This does just what we want. (If you want to try it out for the current session, before making it permanent in .inputrc, type
bind 'Meta-w: "\C-w\C-y\ \C-y"' at the bash command line.)
cheers...