 |
 |
navigating around the commandline
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2000
Location: Raleigh, NC, USA
Status:
Offline
|
|
This is a pretty trivial thing... but it would save me a lot of time in the long run.
Often I'll type a long string in the Terminal, and after hitting Enter, I'll realize that I made a mistake. For instance, maybe I forgot to put "sudo" at the beginning of the command. So, I'll hit the up-arrow to bring it back up. Then I hold down the left-arrow to slowly move the caret to the beginning of the line, so that I can fix the mistake.
My question is... is there any easier way to get the caret to the beginning of the line? None of the typical word processing tricks work (command-arrow, etc).
Thanks :]
Justin
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status:
Offline
|
|
Yes, there is.
Short answer: Control-A.
Long answer: the shell (bash) uses a library called readline which lets you use emacs-style (or optionally vi-style) editing commands at the command line. Some emacs keystrokes that also work in bash:
C-a (means Control-A): go to beginning of line
C-e: go to end of line
C-w: delete one word
C-k: Kill (cut) from cursor to end of line
C-y: Yank (paste)
And a bash-only one:
C-x C-e: Edit the command line in your $EDITOR (probably vi or nano if you haven't set it up)
Really long answer: "man bash" and/or "man readline"
Oh, and when you forget to type sudo: '!!' expands to the last command entered, so you can just type 'sudo !!' and it will do what you want.
|
pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2000
Location: Raleigh, NC, USA
Status:
Offline
|
|
Man, I should have asked that question a looong time ago
Thanks a lot... don't know how I've lived without knowing that.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status:
Offline
|
|
One more thing:
Once you become addicted to those keystrokes, try them in a regular Mac text field (like TextEdit). Lots of them work there too, thanks to the good folks at Apple. 
|
pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2000
Location: Raleigh, NC, USA
Status:
Offline
|
|
Oh, beautiful 
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|