8

I know how to select text in git bash console (for example: commit hash) use mouse, but how to do it use keyboard.

1

3 Answers 3

7

If your "git bash console" runs inside cmd.exe (and in typical git installation in Windows it is), then you can use cmd.exe window context menu for selecting and pasting:

  1. Press alt+space — it will bring window context menu.
  2. Press e, k — it will select Edit -> Mark menu option.
  3. Now you can move your text cursor around cmd.exe window with arrow keys.
  4. Select block of text by holding shift key and selecting block with arrow keys.
  5. Press enter to copy selected block of text.

You can also paste text from clipboard into console using alt+space, e, p shortcut.

Note that keyboard shortcuts depend on Windows user interface language, described above commands are for English interface.

3
  • This is super great!! Thanks!
    – jaques-sam
    Commented Oct 30, 2018 at 9:00
  • Better paste shortcuts are available now: stackoverflow.com/questions/38832230/…
    – Vadzim
    Commented Sep 28, 2019 at 18:58
  • 2
    "in typical git installation in Windows it is" it is not. Git Bash runs in Mintty by default.
    – Krzaku
    Commented Oct 10, 2019 at 19:19
2

Hold Shift Key and first click at starting of your text then click the end of your selection

0

With none of the console, even the very good console2, you can't select and copy with the keyboard because the cursor is constrained in the prompt (except entering the menu with alt shortcuts but it's awefull!!)!

With the git bash console that use 'cmd.exe' behind the scene, you should use the the menu to copy/paste.

With console2, that's easier and all text selected is automatically copied and you just have to paste it with ctrl+v.

But if you prefer the powershell console which is quite better than 'cmd.exe', you could install post-it that add a very good git support to your powershell console...

You could also install Win command paste that permit to paste with the shortcut ctrl+v in the 'cmd.exe' console (and others)

Ps and edit: Bash is for Bourne-again shell (not 'bourne another shell like I wrote before...)

1
  • 1
    It's actually Bourne again shell. Commented Mar 8, 2015 at 12:49

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