vterm-toggle
vterm-toggle copied to clipboard
`vterm-toggle-cd` not inserting CD command
Maybe this is me not understanding how the package works, but when I invoke vterm-toggle-cd
I expect it to bring up a vterm buffer and cd
to the location of the last active buffer.
Instead, calling that function inserts ^K
into the vterm buffer, like so
after this, manually calling vterm-toggle-insert-cd
manually works correctly, but my understanding is that vterm-toggle-cd
should be exactly equivalent to manually invokingvterm-toggle
and then vterm-toggle-insert-cd
- for me it's not.
Am I missing something?
tell me the value of (vterm--prompt-tracking-enabled-p)
and I think you should enable
Directory tracking and Prompt tracking
https://github.com/akermu/emacs-libvterm#directory-tracking-and-prompt-tracking
https://github.com/akermu/emacs-libvterm#shell-side-configuration
or custom term-prompt-regexp
, make it match your prompt .
@jixiuf it's nil
- and I've properly set up directory and prompt tracking for zsh
as per those instructions - I'm on macOS and am using a custom ZSH prompt but I assume that even with a custom prompt the below is all I should need for this to work:
# Added for Emacs libvterm
vterm_printf(){
if [ -n "$TMUX" ]; then
# Tell tmux to pass the escape sequences through
# (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324)
printf "\ePtmux;\e\e]%s\007\e\\" "$1"
elif [ "${TERM%%-*}" = "screen" ]; then
# GNU screen (screen, screen-256color, screen-256color-bce)
printf "\eP\e]%s\007\e\\" "$1"
else
printf "\e]%s\e\\" "$1"
fi
}
vterm_prompt_end() {
vterm_printf "51;A$(whoami)@$(hostname):$(pwd)";
}
setopt PROMPT_SUBST
PROMPT=$PROMPT'%{$(vterm_prompt_end)%}'
Inside the vterm, this is the value of $PROMPT
/ » echo $PROMPT useer@machine
$FG[237]------------------------------------------------------------%{$reset_color%}
$FG[032]%~\
$(git_prompt_info) \
$FG[105]%(!.#.»)%{$reset_color%} %{$(vterm_prompt_end)%}
it's weird the value of (vterm--prompt-tracking-enabled-p)
is nil
.
does you eval (vterm--prompt-tracking-enabled-p)
in vterm buffer.
I have the same problem but without the ^K
part. Doing vterm-toggle-cd
has exactly the same effect as vterm-toggle
.
My workaround is this:
(defun tmalsburg-vterm-toggle-cd-show ()
(interactive)
(vterm-toggle-cd-show)
(vterm-toggle-insert-cd))
(define-key vterm-mode-map [f4] 'tmalsburg-vterm-toggle-cd-show)
I had the same issue. (vterm--prompt-tracking-enabled-p) is nil. for me as well.
My experience with vterm-toggle-cd
is the following:
- if no vterms exist, this behaves as documented (new vterm in the right directory)
- if a vterm exists in a different folder, this toggles it and shows a message about
vterm-toggle-insert-cd
, but it doesn't insert it automatically. -
vterm--prompt-tracking-enabled-p
is2
for me