Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Can do it even faster' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Can do it even faster
Authored by: hayne on Jul 10, '02 12:42:17PM

You can do it with fewer keystrokes:
% ^x^X
will change the first "x" to an "X" - which is all that is required in the example given.

This 'caret' technique is even more useful when combined with other shell history features. E.g. suppose I recall that I had sometime in the recent past copied a file to some directory and I now wanted to copy a different file to that same directory. I could get that previous command to be the latest one in my history list by using ":p":

!?cp:p

This finds the last command where I used 'cp' and echos it (without executing it). Suppose it shows up as:
cp foo /Volumes/Disk42/long/directory/path
then to copy the file "bar" to the same directory, I need only do:
^foo^bar



[ Reply to This | # ]
Can do it even faster
Authored by: seb2 on Jul 11, '02 04:10:00AM

Not only does ":p" show the line that matched, it also appends it to your history, so if the command was right, a single hit on the cursor key "arrow up" brings you there. -- I use it all the time.



[ Reply to This | # ]