Shell: how to go to the beginning of line when you are inside a screen?

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Use Ctrla a, or change screen’s escape keystroke (option -e).

Method 2

CtrlxCtrlx 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 Ctrlaa, 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.

Method 3

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x