Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vterm-toggle-cd not inserting CD command #13

Open
bleggett opened this issue Jul 9, 2020 · 6 comments
Open

vterm-toggle-cd not inserting CD command #13

bleggett opened this issue Jul 9, 2020 · 6 comments

Comments

@bleggett
Copy link

bleggett commented Jul 9, 2020

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
Screen Shot 2020-07-09 at 12 38 24 PM

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?

@jixiuf
Copy link
Owner

jixiuf commented Jul 10, 2020

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 .

@bleggett
Copy link
Author

bleggett commented Jul 10, 2020

@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)%}

@jixiuf
Copy link
Owner

jixiuf commented Jul 11, 2020

it's weird the value of (vterm--prompt-tracking-enabled-p) is nil.
does you eval (vterm--prompt-tracking-enabled-p) in vterm buffer.

@tmalsburg
Copy link

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)

@adouzzy
Copy link

adouzzy commented Jul 20, 2021

I had the same issue. (vterm--prompt-tracking-enabled-p) is nil. for me as well.

@indigoviolet
Copy link

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 is 2 for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants