6

In bash I can hit Ctrl + a and go to first of the command line.

But in screen Ctrl + a does not do this. How do I go to first of command line in screen?

Mohsen
  • 2,585
  • 1
    set -o vi: Space (if you are in insert mode) 0. Done :) – jasonwryan Aug 07 '13 at 04:33
  • I use a less invasive prefix: escape ^\\\ (Ctrl+backslash, press backslash again to send a literal chr(28)) – Gilles 'SO- stop being evil' Aug 07 '13 at 22:41
  • Duplicates: https://unix.stackexchange.com/questions/29450/shell-how-to-go-to-the-beginning-of-line-when-you-are-inside-a-screen, https://unix.stackexchange.com/questions/72119/ctrl-a-does-not-take-me-to-the-beginning-of-the-prompt-while-i-am-working-within – DilithiumMatrix Jun 12 '18 at 17:43

2 Answers2

6

You can press Ctrl+a followed by a to go to the beginning of the line. The a sends a Ctrl+a to the terminal.

jordanm
  • 42,678
1

The long way

Take a look at this Q&A from SuperUser, titled: Bash vs. Gnu screen : Replace Ctrl-A with Ctrl-Shift-A. There are several options but the easiest would be to remap Ctrl+aCtrl+a to something else for screen so that Ctrl+a can be freed for use by Bash.

excerpt from one of the answers

By default, C-a C-a is bound to the other command (switch to most recently active screen) in screen. To have C-a C-a send an actual C-a and have C-a o switch windows, put the following in your .screenrc:

escape ^A^A
bind o other

The short way

As @jordanm has pointed out in the comments. The above solution isn't necessary, however. The 2nd highest upvoted answer to that same Q&A states that you can simply type Ctrl+a+a and screen will send a Ctrl+a to Bash.

slm
  • 369,824
  • I don't necessary want to use C+a. Is there any shortcut specific to screen? – Mohsen Aug 07 '13 at 04:08
  • You failed to mention the second most upvoted answer in that thread http://superuser.com/a/237223/190213. It's the most straightforward (IMO) and the method I personally use. – jordanm Aug 07 '13 at 04:19
  • @jordanm - didn't scroll that far down. 8-). I've never run into this issue, I use tmux. – slm Aug 07 '13 at 04:23
  • @Mohsen - see updates. – slm Aug 07 '13 at 04:29