Reputation: 66488
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?
Upvotes: 4
Views: 390
Reputation: 20248
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>
(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:
cat >/dev/null
in a terminalAnother way to find them would be to type in a terminal: C-vC-<left>
Upvotes: 4