I’ve been trying to get iex to work a spacemacs terminal but it doesn’t seem to be sending the up or down arrows to cycle through history.
I found this possible solution but don’t understand enough about spacemacs/emacs to get it working.
https://groups.google.com/forum/#!topic/elixir-lang-talk/2q_j-zcB2uc
I tried adding this to my user-config but it didn’t do anything.
(defun term-send-up () (interactive) (term-send-raw-string “\e[A”))
(defun term-send-down () (interactive) (term-send-raw-string “\e[B”))
(defun term-send-right () (interactive) (term-send-raw-string “\e[C”))
(defun term-send-left () (interactive) (term-send-raw-string “\e[D”))
Has anyone else been able to get iex working in a spacemacs terminal?
I know alchemist iex is an option but I really prefer iex from a terminal? (alchemist iex seems to keep its own history of commands or something instead of actually sending the up arrow command to iex)
4 Likes
alanm
March 11, 2017, 7:37pm
2
Copy and paste this:
(defun term-send-up () (interactive) (term-send-raw-string “\e[A”))
(defun term-send-down () (interactive) (term-send-raw-string “\e[B”))
(defun term-send-right () (interactive) (term-send-raw-string “\e[C”))
(defun term-send-left () (interactive) (term-send-raw-string “\e[D”))
In your spacemacs.local between (defun dotspacemacs/user-init () and (defun dotspacemacs/user-config () as shown in the following:
...
(defun dotspacemacs/user-init ()
...
)
(defun term-send-up () (interactive) (term-send-raw-string "\e[A"))
(defun term-send-down () (interactive) (term-send-raw-string "\e[B"))
(defun term-send-right () (interactive) (term-send-raw-string "\e[C"))
(defun term-send-left () (interactive) (term-send-raw-string "\e[D"))
(defun dotspacemacs/user-config ()
...
restart spacemacs.
Now you have to use a terminal ‘shell’ instead of the default’ansi-term’ terminal, use spc-a-s-i to open a shell terminal, inside there you can cycle through commands history in the prompt using arrow keys, in erl and in iex.
hope it helps.
2 Likes
You can do this in ‘user-config’ as following:
(defun mo/term-send-up () (interactive) (term-send-raw-string "\e[A"))
(defun mo/term-send-down () (interactive) (term-send-raw-string "\e[B"))
(defun mo/term-send-right () (interactive) (term-send-raw-string "\e[C"))
(defun mo/term-send-left () (interactive) (term-send-raw-string "\e[D"))
(defun mo/setup-term-send-arrow-keys ()
(evil-local-set-key 'insert (kbd "<up>") 'mo/term-send-up)
(evil-local-set-key 'insert (kbd "<down>") 'mo/term-send-down)
(evil-local-set-key 'insert (kbd "<right>") 'mo/term-send-right)
(evil-local-set-key 'insert (kbd "<left>") 'mo/term-send-left)
)
(add-hook 'term-mode-hook 'mo/setup-term-send-arrow-keys)
4 Likes