Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am inside a screen (screen -Ra). I have a long command, and I am at the end. Instead of keeping the left arrow, how can you go to the beginning of the line?

CTRL-A works when I am in a normal window, but when I am inside a screen pressing CTRL-A gives me a message "No other window" - seems like CTRL-A is dispatched to the screen.

How do you go to the beginning of a line in a screen?

share|improve this question
1  
Quick fix: press the Home key to get to the beginning, and End to get to the end of line. –  Herman Torjussen Jan 19 '12 at 12:23
1  
This is also highly dependent upon the shell and input mode youre using, though I'm assuming youre using bash and the default emacs bindings. –  Patrick Jan 19 '12 at 13:18
    
@hesse given your keyboard has a Home button. Not always the case –  Matteo Jan 19 '12 at 15:04
    
@hesse its mac keyboard! –  user11498 Jan 19 '12 at 19:40
    
The OP might be interested in this related question. –  dotancohen Nov 30 '12 at 10:22

3 Answers 3

up vote 22 down vote accepted

Use Ctrl-a a, or change screen's escape keystroke (option -e).

share|improve this answer

Either you can change the screen bindings or you can change the bindings of your shell. Assuming your shell is bash, the output of bind -p | grep \C-a should give you the current action binded to Ctrl+A. To bind this action to something else use the following form:

$ bind '"\C-p": beginning-of-line'

This will bind Ctrl+P to move the cursor to the beginning of the line. Remember the double-quotes inside the expression. To unset a binding you would just set it to nothing:

$ bind '"\C-a": '

To list all input sequences associated with the action, use:

$ bind -p | grep beginning-of-line

Lastly, to make the bindings permament you can put the statements in your ~/.bashrc file and issue source ~/.bashrc.

share|improve this answer
1  
+1 good explanation. –  user11498 Jan 19 '12 at 20:22

Ctrl-x-Ctrl-x lets you go to the first character of the line for any readline-compatible environment like Bash, python and mysql. GNU SCREEN safely ignores this. No customized configuration necessary.

If you use this instead of Ctrl-a-a, you use a consistant shortcut key - you don't have to keep in mind whether you are in GNU SCREEN or not.

For anyone interested, the same shortcut key also lets you go to the end of the line if you are already at the begining.

share|improve this answer
    
Actually, C-x C-x is exchange-point-and-mark. It just happens that mark is at the beginning of the line by default. You can use C-space to set the mark somewhere else. –  Ivan Andrus Apr 21 at 17:29

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.