2

I've been trying to get shell code blocks with sessions to work, but not entirely succeeding.

My setup: emacs 26.1 (spacemacs) org-mode 9.2.2 default shell: zsh 5.7.1

Everything seems to work fine with sh but it fails with shell.

Ordinary, non-session execution works:

#+begin_src shell
  echo ${TERM}
  echo ${0}
#+end_src

#+RESULTS:
| dumb         |
| /usr/bin/zsh |

However, when I try to add a session I don't get the result I expect

#+begin_src shell :session s1
  FOO=bar
  echo ${TERM}
  echo ${0}
#+end_src

#+RESULTS:
|                                                       |
| magthecomp% 

[?2004hmagthecomp% FOO=bar[?2004l |

and on further use of that session emacs freezes up and I have to interrupt it (<Ctrl-g>), for instance if I try to execute

#+begin_src shell :session s1
  echo ${FOO}
#+end_src

When I take a look at the session buffer I see the following after running those blocks

FOO=bar
magthecomp% echo ${TERM}
magthecomp% FOO=bar
echo ${0}
echo ${0}
echo 'org_babel_sh_eoe'
echo 'org_babel_sh_eoe'
magthecomp% echo ${TERM}echo ${0}
dumbecho /usr/bin/zsh
            echo 'org_babel_sh_eoe'
org_babel_sh_eoe
magthecomp% echo ${FOO}
echo ${FOO}echo 'org_babel_sh_eoe'
            echo ${FOO}echo 'org_babel_sh_eoe'

(some colour is lost when copying it)

I already toned down the theme for my shell prompt when ${TERM} == "dumb", but apparently that isn't enough. Any pointers on how to adjust my zsh config to make it work would be much appreciated.

  • Seeing this too. Using GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.5.0, Carbon Version 158 AppKit 1671.4) - via MacPorts emacs-app. Also using zsh... – alls0rts Jun 6 at 15:22
  • To confirm, in the session buffer your seeing the prompt is coloured (blue for me) and errors are coloured too (green for me). Seems emacs is adding this colour and not zsh. Could this be what org-mode babel results output is picking up, the colour codes? – alls0rts Jun 6 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.