View previous topic :: View next topic |
Author |
Message |
tipp98 Tux's lil' helper
Joined: 28 Jan 2007 Posts: 113
|
Posted: Wed Aug 26, 2009 6:52 pm Post subject: repeat the last command with a new arguement? |
|
|
Anyone have any tricks on how to do this?
There is ^old^new, but sometimes I have a short memory and forget what I just typed :\
I tried making a script, but found history doesn't work inside scripts.
Code: |
last=$(!!$)
^${last}^${1}
|
|
|
Back to top |
|
|
truc Advocate
Joined: 25 Jul 2005 Posts: 3199
|
Posted: Wed Aug 26, 2009 8:01 pm Post subject: |
|
|
have a look at the readline manual
typing C-P C-W tist will give you
or you can also type
or even C-A-0 C-Y toto which will do a
really, check the readline manual, there are a lot of valuable information:) _________________ The End of the Internet!
Last edited by truc on Thu Aug 27, 2009 8:02 am; edited 1 time in total |
|
Back to top |
|
|
coolsnowmen Veteran
Joined: 30 Jun 2004 Posts: 1479 Location: No.VA
|
Posted: Wed Aug 26, 2009 8:10 pm Post subject: Re: repeat the last command with a new arguement? |
|
|
tipp98 wrote: |
I tried making a script, but found history doesn't work inside scripts.
|
that isn't the problem. functions or aliases can get around that, the problem is your command can't work because of order of operations
the bash command substitution will not dereference a variable inside of the substitution string.
Or rather I can't get it too:
Code: | ~ $ echo john
john
~ $ ^john^fred^
echo fred
fred
~ $ echo john
john
~ $ last="!!$"
last="john"
^${last}^fred^
bash: :s^${last}^fred^: substitution failed
|
I simply think it would be faster to do this:
try your command that you want to redo
then do Ctrl-p-w (just hit 'p' and 'w' in succession, no need to hold them down together. _________________ emerge: there are no ebuilds to satisfy "moo" |
|
Back to top |
|
|
|