📜 ⬆️ ⬇️

Move the cursor to the Terminal

In my case, Terminal.app is one of the most widely used applications in the operating system. And the first thing that seems inconvenient is a reaction to the usual keyboard shortcuts regarding cursor movement. Let me explain by the example of graphic applications. You probably often have to work with text editing, and use keyboard shortcuts using arrows and system keys to move the cursor to the beginning of a word or line. So I have to disappoint you, but in the terminal these tricks will not work. Until we go there with a file. For the cause.

In fact, I put it not quite correctly. The above steps can be done, but you will have to use several other combinations. Which ones? In response to this question, I compared the keyboard shortcuts performed in the graphical interface with those used in the terminal, and captured the result in the following table:

ActionsGUITerminal
Move the cursor
to the beginning of the word
Option ⌥ + Left key ←Esc ⎋ + B
Move the cursor
by the end of the word
Option ⌥ + Right key →
Esc ⎋ + F
Move the cursor
at the end of the text
Option + Down key ↓Control ⌃ + A or
Shift + Home ↖
Move the cursor
to the beginning of the text
Option ⌥ + Up key ↑Control ⌃ + E or
Shift + End ↘
Delete the word
in front of the cursor
Option ⌥ + Backspace ⌫Control + W or
Option ⌥ + Backspace ⌫
Delete the word
after the cursor
Option ⌥ + Delete ⌦Esc ⎋ + D


At the moment, my goal is to bring everything to any one scheme. Technically, it is much easier to simply configure the terminal, which, by the way, has quite flexible settings. We need to go to the Settings menu, the Keyboard submenu. For those who have Russian localization, you can see the screenshot below to get your bearings:
')


In the terminal, you can work both locally and remotely. In order to achieve more complete compatibility with other operating systems, in terms of control from the keyboard, we will need to tick the “Use option as meta key” box. This action will also eliminate the problems that may arise when using some text editors. Now back to what was intended. Click the button “Add key setting”, which is depicted as a mathematical plus sign, and enter your settings for each action. About this in order:
  1. Move the cursor to the beginning of the word.
    Key: cursor left
    Modifier: option
    Action: send string to shell
    In the input field, press "Esc ⎋ + B" or paste the code "\ 033b"
  2. Move the cursor to the end of the word.
    Key: cursor right
    Modifier: option
    Action: send string to shell
    In the input field, press "Esc ⎋ + F" or paste the code "\ 033f"
  3. Move the cursor to the beginning of the text.
    Key: cursor up
    Modifier: option
    Action: send string to shell
    In the input field, click "Control ⌃ + E" or paste the code "\ 005"
  4. Move the cursor to the end of the text.
    Key: cursor down
    Modifier: option
    Action: send string to shell
    In the input field, click "Control ⌃ + A" or paste the code "\ 001"
  5. Delete the word after the cursor.
    Key: forward delete
    Modifier: option
    Action: send string to shell
    In the input field, press "Esc ⎋ + D" or paste the code "\ 033d"




In addition, it is worth mentioning the additional keyboard shortcuts that are available either in graphical applications or only in the terminal:

ActionsGUITerminal
Delete lineCommand + Backspace ⇧-
Delete all to the left of the cursor-Control ⌃ + U
Delete all to the right of the cursor.-Control ⌃ + K


Of course, everything is individual and each sees in its own way a perfectly tuned Terminal. With questions or comments, welcome to comments.

Source: http://snupt.com

Source: https://habr.com/ru/post/74807/


All Articles