Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am having issues writing to the end of a line in my terminal. I can type fine but when I move left to edit the line (using the arrow keys), I cannot use the arrow keys to go back to the end of the line. I can jump to the end of the line using the alt + up or move to the last second to the last character and press delete and start typing at the end of the line again. Does anyone know about this bug? Or is it possible that by editing my bash_profile I removed something that would help fix this bug?

Is there anyway to use the arrow keys to move?

Thanks

export PATH=/usr/local/bin:$PATH
#Create prompt with colors
function prompt
{
# \[ sets the charcters to no over write so the line wraps correctly
     local RED="\[\e[0;31m\]"
     local BLACK="\[\e[1;30m\]"
     local WHITE="\[\e[0;0m\]"
     local GREEN="\[\e[1;32m\]"
     local PLAIN="\[\e[m\]"

     export PS1="${BLACK}${RED}\W ${GREEN}- ${WHITE}${PLAIN}"
}
set prompt="%{e[?7h%}%m%# "
prompt

# File and Directory Highlighting
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

# Terminal Options
set complete=enhance
set autolist=v
set implicitcd
set -o noclobber 
set -o vi

# RVM path
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
share|improve this question

migrated from stackoverflow.com Nov 18 '11 at 2:30

This question came from our site for professional and enthusiast programmers.

    
Wait. When you say "move" using the arrow keys, do you mean move in a normal manner (i.e. character by character)? Or do you want the arrow keys to jump you to the end of the line automatically? –  lunchmeat317 Nov 18 '11 at 2:25
    
Normal move character by character –  trev9065 Nov 18 '11 at 2:35
    
So, have you tried Dean's suggestions? –  slhck Nov 18 '11 at 11:21

5 Answers 5

up vote 1 down vote accepted

Your bash_profile could be the culprit. I had an a small error when specifying how I wanted my prompt to look, and it caused all kinds of strange errors.

try:

mv ~/.bash_profile ~/.bash_profile.bak
touch ~/.bash_profile
source ~/.bash_profile

This will give you an empty bash_profile. If it fixes the problem, then you know who your enemy is.

share|improve this answer
1  
This is actually a very good suggestion. I'd give it a try. –  lunchmeat317 Nov 18 '11 at 2:38
    
@dean So this proved that it was my something to do with my bash. Any chance you figures out what the error was? –  trev9065 Dec 1 '11 at 4:50
    
Do you mean that you confirmed that it's your bash_profile file causing the issue? If that's the case, then finding the problem should be easy. Just comment out half of your bash_profile, source it, and see if that fixes the problem. If it does, you know that the error is in the commented out part. Keep doing that until you're down to the one line or section that's causing the problem. –  Dean Dec 1 '11 at 17:07

ctrl + a moves to the beginning. ctrl + e moves to the end.

share|improve this answer
    
But there is no way to move using the arrows? –  trev9065 Nov 18 '11 at 2:19
    
not that i know of –  hvgotcodes Nov 18 '11 at 2:22

I don't think that this is an issue with your bash_profile or any of the bash config files; I'm pretty sure that bash doesn't configure cursor movement. (Actually, that's not quite right. Bash can interpret key commands, but I wouldn't imagine that that's your problem here.)

If you're using the OSX terminal, go into Terminal->Preferences and go to Settings. Under the Keyboard subtab, make sure that your "control cursor left" and "control cursor right" are set to the default values (\033[5D and \033[5C, respectively).

Additionally, why not post your .bashrc and .bash_profile here? We might be able to find an error, if there is one. Again, I don't think that any of the bash config files actually control cursor movement, but I might not be fully correct. (For instance, the up and down keys in Bash recall history, which /bin/sh does not do.)

share|improve this answer
    
posted the bash_profile, and the arrow keys are mapped as specified above in the keyboard preferences. –  trev9065 Nov 18 '11 at 2:36

You could use iTerm like I do, then you can set your keybindings in preferences. You also get a whole bunch of other features. Highly recommended to Mac developers.

share|improve this answer

I just had this same problem after getting some .bash_profile settings from someone else. The offending line is here:

set -o vi

That sets up the terminal to use vi-style keybindings and edit mode. Useful stuff, as long as you realize it's happening. If you don't realize what's happening it just seems like you can't move the cursor beyond the last character in the line.

Here's some info about vi mode in bash:

http://www.catonmat.net/blog/bash-vi-editing-mode-cheat-sheet/

share|improve this answer
    
The bug is specific to vi mode, BUT, it is still a bug. See: unix.stackexchange.com/questions/75035/… –  kiyo Mar 14 at 17:04

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.