ctrlshiftbryan

ctrlshiftbryan

IEx in Spacemacs terminal

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)

Most Liked

modraedlau

modraedlau

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)
alanm

alanm

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.

Where Next?

Popular in Questions Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement