Действительно ли там кто-либо является ручным для получения списка сочетаний клавиш удара?

Существует много ярлыков, которые я использую при взаимодействии с командной строкой удара для создания работы легче и быстрее.

Как:

  • ctrl+L: очистить экран
  • ctrl+a/ctrl+e: для перемещения запускают/заканчивают строки
  • ctrl+r: искать историю команды, просто пишущий немногие символы
  • ctrl+u/ctrl+y: сокращать/вставлять строку.

и еще много, которых я хочу знать и который будет определенно полезный для изучения.

Я хочу знать от того, где я могу получить список этих ярлыков в Ubuntu? Действительно ли там кто-либо является ручным, который перечисляет эти ярлыки?

Примечание:

Я хочу получить список ярлыков и их действий в одном месте. Это действительно поможет изучить многие из них в маленькой продолжительности времени. Так есть ли способ, которым мы можем получить список как это? Хотя благодарит ответ, данный здесь..

21
задан 8 April 2014 в 20:40

5 ответов

Значения по умолчанию находятся в man bash, наряду с деталями относительно того, что делает каждая команда. См. ответ BroSlow при изменении привязок клавиш.

   Commands for Moving
       beginning-of-line (C-a)
              Move to the start of the current line.
       end-of-line (C-e)
              Move to the end of the line.
       forward-char (C-f)
              Move forward a character.
       backward-char (C-b)
              Move back a character.
       forward-word (M-f)
              Move forward to the end of the next word.  Words are composed of alphanumeric characters (letters and digits).
       backward-word (M-b)
              Move back to the start of the current or previous word.  Words are composed of alphanumeric characters (letters and digits).
       shell-forward-word
              Move forward to the end of the next word.  Words are delimited by non-quoted shell metacharacters.
       shell-backward-word
              Move back to the start of the current or previous word.  Words are delimited by non-quoted shell metacharacters.
       clear-screen (C-l)
              Clear the screen leaving the current line at the top of the screen.  With an argument, refresh the current line without clearing the screen.

...

       reverse-search-history (C-r)
              Search backward starting at the current line and moving `up' through the history as necessary.  This is an incremental search.

...

       unix-line-discard (C-u)
              Kill backward from point to the beginning of the line.  The killed text is saved on the kill-ring.

...

       yank (C-y)
          Yank the top of the kill ring into the buffer at point.

Править

Эти команды - все в непрерывном разделе руководства, таким образом, можно просмотреть его от Commands for Moving. С другой стороны, можно сохранить этот весь раздел к текстовому файлу с

man bash | awk '/^   Commands for Moving$/{print_this=1} /^   Programmable Completion$/{print_this=0} print_this==1{sub(/^   /,""); print}' > bash_commands.txt

(N.B. это печатает целый раздел, включая команды без сочетания клавиш по умолчанию.)

Объяснение кода awk

  • На (единственном) возникновении Commands for Moving, установите переменную print_this к 1.
  • На (единственном) возникновении Programmable Completion, который является следующим разделом, установите переменную на 0.
  • Если переменная равняется 1, то избавьтесь от ведущего пробела (три пробелов) и распечатайте строку.
22
ответ дан 16 November 2019 в 12:16

Можно перечислить все ярлыки в текущей оболочке удара путем называния удара встроенным bind с -P опция.

, например,

bind -P | grep clear
clear-screen can be found on "\C-l".

Для изменения их можно сделать что-то как

 bind '\C-p:clear-screen'

И поместить его в init файл для создания его постоянным (обратите внимание, что можно было только связать сочетание клавиш с одной вещью за один раз, таким образом, это потеряет любую привязку, это имело ранее).

20
ответ дан 16 November 2019 в 12:16

Следующая команда дает хороший колоночный вывод, показывающий использование и ярлыки.

bind -P | grep "can be found" | sort | awk '{printf "%-40s", $1} {for(i=6;i<=NF;i++){printf "%s ", $i}{printf"\n"}}'

Это дает вывод, который похож

abort                                   "\C-g", "\C-x\C-g", "\e\C-g". 
accept-line                             "\C-j", "\C-m". 
backward-char                           "\C-b", "\eOD", "\e[D". 
backward-delete-char                    "\C-h", "\C-?". 
backward-kill-line                      "\C-x\C-?". 
backward-kill-word                      "\e\C-h", "\e\C-?". 
backward-word                           "\e\e[D", "\e[1;5D", "\e[5D", "\eb". 
beginning-of-history                    "\e<". 
beginning-of-line                       "\C-a", "\eOH", "\e[1~", "\e[H". 
call-last-kbd-macro                     "\C-xe". 
capitalize-word                         "\ec". 
character-search-backward               "\e\C-]". 
character-search                        "\C-]". 
clear-screen                            "\C-l". 
complete                                "\C-i", "\e\e". 
...

Получите этот вывод в использование текстового файла после команды

bind -P|grep "can be found"|sort | awk '{printf "%-40s", $1} {for(i=6;i<=NF;i++){printf "%s ", $i}{printf"\n"}}' > ~/shortcuts

Файл создается в Вашем каталоге $HOME.

Объяснение

  • получает все ярлыки.

    bind -P
    
  • удаляет все неприсвоенные ярлыки

    grep "can be found"
    
  • сортирует вывод

    sort
    
  • печатает первый столбец (т.е. функция) и выравнивает текст

    awk '{printf "%-40s", $1}
    
  • Это - часть предыдущей команды. Это печатает столбцы 6 + (т.е. ярлыки).

    {for(i=6;i<=NF;i++){printf "%s ", $i}{printf"\n"}}'
    
  • Помещает вывод в хороший текстовый файл в названных ярлыках домашнего dir

    > shortcuts
    

Можно получить идею того, как команда работает путем выполнения следующих команд.

bind -P
bind -P | grep "can be found"
bind -P | grep "can be found" | sort
7
ответ дан 16 November 2019 в 12:16

Хорошо у меня есть способ получить список ярлыков путем фильтрации руководства удара. Это также даст описание, что точно делает каждый ярлык. Благодаря Sparhawk, кто просветил меня для нахождения решения. То, в чем я нуждался, должно было изучить использование регулярных выражений, хотя я все еще не хорош в нем :)

Таким образом, вот одна команда строки:

man bash | grep "(.-.*)$" -A1

Вот маленькое извлечение вывода:

   beginning-of-line (C-a)
          Move to the start of the current line.
   end-of-line (C-e)
          Move to the end of the line.
   forward-char (C-f)
          Move forward a character.
   backward-char (C-b)
          Move back a character.
   forward-word (M-f)
          Move forward to the end of the next word.  Words are composed of alphanumeric characters (letters and digits).
   backward-word (M-b)
          Move back to the start of the current or previous word.  Words are composed of alphanumeric characters (letters and digits).
   clear-screen (C-l)
          Clear the screen leaving the current line at the top of the screen.  With an argument, refresh the current line without clearing the
   previous-history (C-p)
          Fetch the previous command from the history list, moving back in the list.
   next-history (C-n)
          Fetch the next command from the history list, moving forward in the list.
   beginning-of-history (M-<)
          Move to the first line in the history.
   end-of-history (M->)
          Move to the end of the input history, i.e., the line currently being entered.
   reverse-search-history (C-r)
          Search backward starting at the current line and moving `up' through the history as necessary.  This is an incremental search.
   forward-search-history (C-s)
          Search forward starting at the current line and moving `down' through the history as necessary.  This is an incremental search.

Теперь сохранить ярлыки на файл:

man bash | grep "(.-.*)$" -A1 > bash_shortcuts

Это - все, в чем я нуждался. Я просто хотел знать сочетания клавиш, присвоенные удару, и я не реконфигурировал ключей, как BroSlow попросил меня.

Еще раз благодаря всем для их вкладов.

Примечание:

Если кто-то хочет улучшить это, он больше всего встречен. Я только упомянул способ перечислить те ярлыки, которые были присвоены некоторыми ключами. Таким образом, если кто-то знает, как перечислить те действия, которые не были присвоены с описанием с помощью этого пути, больше всего одобрен :)

1
ответ дан 16 November 2019 в 12:16

Пока руководство удара не изменяется способом для создания этой команды неподходящей (который не вероятен), следующая команда покажет все ярлыки по умолчанию для bash.

man bash | grep -A294 'Commands for Moving'

Это дает вывод, который похож:

 Commands for Moving
   beginning-of-line (C-a)
          Move to the start of the current line.
   end-of-line (C-e)
          Move to the end of the line.
   forward-char (C-f)
          Move forward a character.
   backward-char (C-b)
          Move back a character.
   forward-word (M-f)
          Move forward to the end of the next word.  Words are composed of alphanumeric characters (letters and digits).
   backward-word (M-b)
          Move back to the start of the current or previous word.  Words are composed of alphanumeric characters (letters  and
          digits).
   shell-forward-word
          Move forward to the end of the next word.  Words are delimited by non-quoted shell metacharacters.
   shell-backward-word
          Move back to the start of the current or previous word.  Words are delimited by non-quoted shell metacharacters.
   clear-screen (C-l)
          Clear  the  screen  leaving  the  current line at the top of the screen.  With an argument, refresh the current line
          without clearing the screen.
   redraw-current-line
          Refresh the current line.

Commands for Manipulating the History
   accept-line (Newline, Return)
          Accept the line regardless of where the cursor is.  If this line is non-empty, add it to the history list  according
          to  the state of the HISTCONTROL variable.  If the line is a modified history line, then restore the history line to
          its original state.
   previous-history (C-p)
          Fetch the previous command from the history list, moving back in the list.
   next-history (C-n)
...

, Если руководство удара изменяется, эта команда может легко быть изменена для установки потребностям.

1
ответ дан 16 November 2019 в 12:16

Другие вопросы по тегам:

Похожие вопросы: