by aabajian · 10y ago · 0 comments
>rsync ~/20160604/apache-tomcat-7.0.63/webapps/ROOT/contact.html apache-tomcat-1:/svr/apache-tomcat-7.0.63/webapps/ROOT/
I'm rsyncing the contact.html file to my website. Now I want to rsync the index.html page. I do this by:
1. Pressing the up arrow key to get the previous command.
2. Press and hold the back arrow key until it gets to "contact.html"
3. Press and hold backspace to delete "contact.html" and type "index.html"
My question is: How to quickly move the cursor to a location on the line. For example, in Vi I could do "F+c" twice to move to the first "c" if this were a text file. I know I can enabled Vi commands for Bash, but this seems cumbersome. There has to be a way in Bash to jump around the already typed line.
Typing "Ctrl-r aString" will recall the previous command and position the cursor where the string "aString" occurs. You can then Alt-d, Ctrl-w, whatever.
> $ mroe file1 ; mroe file2
> $ !!:gs/mroe/more
But instead, you would do:
>$ rsync ~/20160604/apache-tomcat-7.0.63/webapp /ROOT/contact.html apache-tomcat-1:/svr/apache-tomcat-7.0.63/webapps/ROOT/
> $ !!:gs/contact/index
"\e[1;5C":forward-word
"\e[1;5D":backward-word
The readline manual shows more sophisticated argument operations. Zsh, IIRC, has more features for command processing.Otherwise, typing ^contact^index after your step 1 should also work.
M-b: back one word
M-f: forward one word
C-a: beginning of line
C-e: end of line
I also don't like to use the arrow keys because they are so far away, so:
C-b: back one character
C-f: forward one character
C-p: previous command
C-n: next command
And since I'm making a list now anyway:
C-k: Kill to end of line.
C-u: Kill to beginning of line.
C-y: Yank (put/paste) last killed string. You can then cycle further through the kill ring with M-y.
But I have a question concerning Emacs movement: M-b and M-f are rather similar to vim's b and e, respectively, meaning they don't jump to the beginning/end of the non-whitespace-string. That's why vim has B and E. Is there anything similar in Emacs?
Alt+<number> followed by that goes to that <number> occurrence of the character, so "Alt+4 Ctrl+] c" would go to the 4th c. Ctrl+Alt+] searches backwards in the same way.
But I find just about anything better.
!!:s/contact/index/ ^contact^index alias r='fc -e - --' # if not already present r contact=index
or if you know ahead of time, do them both together
rsync ~/20160604/apache-tomcat-7.0.63/webapps/ROOT/{contact,index}.html