Closed Ergus closed 3 years ago
I am running into this problem too now. Can you share your full workaround?
The purpose of the switch statement that we have in the shell-side configuration files is to correctly pass the escape sequences to Emacs. The idea is the following: if you are in Emacs, you can vterm with tmux inside, which would capture all the escape sequences. The switch statement should enable "tmux pass-trough mode", so that we can read the sequences from Emacs.
In theory we should be able to support the other scenario that you mention: you run vterm inside emacs inside tmux. It all boils down to what shell variables are inherited and who is capturing the shell sequences. However, I've never tested this so I am not surprised that there is something wrong.
On the other hand tmux does not import variables like INSIDE_EMACS unless they are added in the tmux option: update-environment so this makes me wonder when is useful that if TMUX condition?
I personally use Emacs as a terminal multiplexers, so I don't know much about tmux, but on my system if I run tmux inside vterm,
and I echo $INSIDE_EMACS
, I find what I expect: vterm
.
and the link in the file: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324 is broken
Thanks!
Turns out Gmane's domain is now gname.io and it is only available via NNTP newsreader, not as a website: https://lars.ingebrigtsen.no/2020/01/15/news-gmane-org-is-now-news-gmane-io/
I am running into this problem too now. Can you share your full workaround?
With the latest fixes in vterm where they added the variable EMACS_VTERM_PATH
; my bashrc config is something like:
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
if [[ -n ${EMACS_VTERM_PATH} ]] \
&& [[ -f ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh ]]; then
source ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh
export TMUX=
else
echo "Error loading vterm config"
fi
fi
This solves my issue when using vterm inside emacs inside tmux which is my current workflow (because I use Tramp a lot). But of course this will break the case of using tmux inside vterm inside emacs... maybe usefull for many other users.
In theory we should be able to support the other scenario that you mention: you run vterm inside emacs inside tmux. It all boils down to what shell variables are inherited and who is capturing the shell sequences. However, I've never tested this so I am not surprised that there is something wrong.
Hi, yes but there is the issue as described in my use case (vterm inside emacs inside tmux),
In my case the problem is because in vterm_printf
the condition if [ -n "$TMUX" ]
will be true because the TMUX
variable will be inherited (from the emacs process-environment
that will get it from the calling tmux environment). So the scape sequences will be wrong as shown. That's why I need to manually unset TMUX in my bashrc as shown in the code.
I personally use Emacs as a terminal multiplexers, so I don't know much about tmux, but on my system if I run tmux inside vterm, and I echo
$INSIDE_EMACS
, I find what I expect:vterm
.Tmux does not inherit any variable unless it is in the
update-environment
as described in the tmux manual. I actually tried tmux inside vterm and echo $INSIDE_EMACS prints nothing to me.
These are both vterm but on the right there is tmux...
I might have a fix for this, which I have submitted in #475. @Ergus can you try it out?
Hi:
I see that the vterm_printf function has an special case when TMUX is defined... I am not sure if it refers to the case of calling tmux from vterm or when calling vterm from an emacs inside a tmux.
and the link in the file: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324
is broken.
When I do:
I get this prompt:
I made a work around with something like this and it solved the issue for the moment:
I know that calling vterm from emacs from tmux looks like a difficult scenario; but sometimes it is useful when working with different files and I need a quick terminal in the current path (vterm-toggle comes to rescue)...
On the other hand tmux does not import variables like INSIDE_EMACS unless they are added in the tmux option:
update-environment
so this makes me wonder when is useful that if TMUX condition?Best, Ergus