ctrl+a → go to beginning of linectrl+e → go to end of linectrl+k → delete to end of lineAnd even though I was very frustrated by the fact that I had to use
the mouse to select/copy/paste etc, it never really occured to me to
google for "bash command line shortcuts"...
To make it short: bash uses the readline library.
The user documentation for readline is at:
http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html
All the shortcuts that exist on your machine can be found by using the
'
bind' command:$ bind -P | moreYou'll have more shortcuts with:
$ bind -p | moreIf you want to know how to use 'bind' to add shortcuts, check its help
file:
$ help bindSelect/cut/paste require to first bind a shortcut to "kill-region":
$ bind "\C-xx": kill-region
(
ctrl+x followed by x)Now we need to select the string (create a "region").
A region is automatically created between a "mark" and the cursor. So, we only need to put the mark at one end of the region and to move the cursor
to the other end.
To create a mark use:
ctrl+@ or ctrl+space, then move the cursor, then hit
ctrl+xx to "kill" the region.
Pasting requires
ctrl+y.But, the
ctrl-y (Yank/paste) command works only within the application from where the string was "killed". The "kill-ring" is
not shared by other applications (even though they may accept
ctrl-y as a Yank command).So, if you want to get a string from terminal and paste it outside
(like select a command and paste it into a mail for ex), here is
something that may not be the most efficient way to go, but it works:
echo string | pbcopyor
echo "complex string" | pbcopyFor ex, to put the above line in the pastebpard, I'd do:
echo "echo \"complex string\" | pbcopy" | pbcopy
2 comments:
Hi,
Do you know what shortcut is used in GoogleDocuments to go to the end of the line?
On my MacBook in Word I use Command+right arrow, but this doesn't work in GoogleDocuments. Very frustrating.
Thx
YaniQC,
I don't use GoogleDocs but since the whole thing runs into Safari, I would suppose standard Safari shortcuts work ?
Did you try other things like Ctrl+a/e/n/p ?
Post a Comment