I use this function to send raw commands to terminal:
我使用此功能向终端发送原始命令:
(defun raw (str)
(interactive "sKey: ")
(term-send-raw-string (read-kbd-macro str)))
But read-kbd-macro
for <C-left>
return [C-left]
which is not a string.
但是对于
I've also try:
我也试一试:
(term-send-raw-string "\C-\eOD")
and
和
(define-key term-raw-map (kbd "<C-left>") 'term-send-raw)
But those also doesn't work.
但这些也不管用。
How can I send C-left then?
那么我怎么发送C-left呢?
1 个解决方案
#1
3
I have the following snippet in my setup file, for the exact same purpose as you: move by words on the bash prompt using C-<arrows>
我在我的设置文件中有以下代码片段,与您的目的完全相同:使用C- <箭头> 在bash提示符上移动。
(defun term-send-Cright () (interactive) (term-send-raw-string "\e[1;5C"))
(defun term-send-Cleft () (interactive) (term-send-raw-string "\e[1;5D"))
(define-key term-raw-map (kbd "C-<right>") 'term-send-Cright)
(define-key term-raw-map (kbd "C-<left>") 'term-send-Cleft)
I found the \e[1;5C
and \e[1;5D
codes using the following trick:
我使用以下技巧找到了\e[1;5C]和\e[1;5D]编码:
- run
cat >/dev/null
in a terminal - 在终端中运行cat >/dev/null
- type C-<left> and C-<right> and see what is echoed back in the terminal
- 类型C- <左> 和C- <右> ,查看终端中回显的内容
- exit with C-d or C-c
- C-d或C-c出口。
Another way to find them would be to type in a terminal: C-vC-<left>
另一种找到它们的方法是输入一个终端:C-vC- <左>
#1
3
I have the following snippet in my setup file, for the exact same purpose as you: move by words on the bash prompt using C-<arrows>
我在我的设置文件中有以下代码片段,与您的目的完全相同:使用C- <箭头> 在bash提示符上移动。
(defun term-send-Cright () (interactive) (term-send-raw-string "\e[1;5C"))
(defun term-send-Cleft () (interactive) (term-send-raw-string "\e[1;5D"))
(define-key term-raw-map (kbd "C-<right>") 'term-send-Cright)
(define-key term-raw-map (kbd "C-<left>") 'term-send-Cleft)
I found the \e[1;5C
and \e[1;5D
codes using the following trick:
我使用以下技巧找到了\e[1;5C]和\e[1;5D]编码:
- run
cat >/dev/null
in a terminal - 在终端中运行cat >/dev/null
- type C-<left> and C-<right> and see what is echoed back in the terminal
- 类型C- <左> 和C- <右> ,查看终端中回显的内容
- exit with C-d or C-c
- C-d或C-c出口。
Another way to find them would be to type in a terminal: C-vC-<left>
另一种找到它们的方法是输入一个终端:C-vC- <左>