Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am at the command line and I have

. /this/set/of/directory/this_command "parm1", "parm2", "parm3"

When I 'up-arrow' to recall previous lines, how can I move along the line from "word to word". Ideally a directory separator slash ("/") will also count as word demarcation.

On other OS's I can use things like ctrl-[left/right]arrow or alt-[left/right] arrow to move "a word at a time" but I haven't yet found any keystroke combination on a mac that will let me do that.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

As a general solution for the bash shell (Linux/Mac) : I set the Vi mode with

$ set -o vi

I have set it in the global /etc/bashrc file.

That way I can navigate with the usual vi keys within a command line after hitting the ESC key.

E.g. changing into Vi mode and then by pressing 'b' I can move back a word. And since the directory seperator counts as a word seperator it would work for your example.

Typing 'w' would move to the right again by a word each time. And so on

share|improve this answer
add comment

In Terminal, you can use opt-[left/right] arrow to navigate word by word. Additionally, you can use opt+click to reposition the cursor.

share|improve this answer
add comment

If you'd prefer not to switch to vi mode, you can check “Use option as meta key” under Preferences… > Settings > any profile > Keyboard. With that enabled you'll be able to hit Opt+B & Opt+F to move backward & forward a word at a time, along with a plethora of other emacs-style shortcuts.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.