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

Remote shell tracking - tramp customizations required? update README if reproducible? #369

Open
twagtwig opened this issue Jul 13, 2020 · 2 comments

Comments

@twagtwig
Copy link

I have to include the following to get dired-jump, and find-file to correctly start on the remote server (from a vterm buffer already ssh'd-in):

;; required to make tramp directory tracking work correctly
(setq tramp-default-method "ssh")
(setq tramp-shell-prompt-pattern "\\(?:^\\|\r\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-zA-Z] *\\)*")

I got it from #55 (comment)
The remote server is Debian 10 cloud.

Can anyone confirm that setting tramp-shell-prompt-pattern is necessary to connect to a remote server with the full shellside configuration from the README?

For reference, here's what I have in my shell on the server:

# https://github.com/akermu/emacs-libvterm
function 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)"
}
PS1=$PS1'\[$(vterm_prompt_end)\]'

If this is the case, I suggest including something about it in the README.

This is in the spirit of #237

More comprehensive documentation: I am not even sure if the documentation covers all the features available in the package for the end user, let alone for developers.

A sentence in the https://github.com/akermu/emacs-libvterm#directory-tracking-and-prompt-tracking section like:

If TRAMP is not correctly configured to understand the custom vterm prompt on remote machines, you may have errors like

File error: Tramp failed to connect.  If this happens repeatedly, try
    ‘M-x tramp-cleanup-this-connection’

when you try to find-file or dired-jump from a vterm buffer. This should solve the problem:

(setq tramp-shell-prompt-pattern "\\(?:^\\|\r\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-zA-Z] *\\)*")
@Sbozzolo
Copy link
Collaborator

I have at the beginning of my remote .rc file the following lines:

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

So the rest of the file is not evaluated and the prompt stays extremely simple.

However, this problem caused multiple headaches to me and to people I know (not necessarily with vterm), so I'll add a note in the README.

@twagtwig
Copy link
Author

Thank you @Sbozzolo , I have that line too in my .bashrc on the server but after some testing it doesn't have any effect on TRAMP for me.
I still got errors like:

Tramp: Waiting for prompts from remote shell...failed
Tramp: Opening connection for root@server using ssh...failed

The only thing that worked for me is

A

In emacs: (setq tramp-shell-prompt-pattern "\\(?:^\\|\r\\)[^]#$%>\n]*#?[]#$%>].* *\\(^[\\[[0-9;]*[a-zA-Z] *\\)*")

B

In .bashrc on the remote server:

vterm_prompt_end(){
    vterm_printf "51;Auser@server:$(pwd)"
}

(Where I replace "user" and "server" with the terms ssh is expecting from my local .ssh/config. Using $(whoami)@$(hostname) didn't work for me because I use an alias in my ssh config.

rennsax added a commit to rennsax/dotfiles that referenced this issue Jul 22, 2024
rennsax added a commit to rennsax/.emacs.d that referenced this issue Jul 26, 2024
Previously it's "scp", which acts weird for vterm-mode.

akermu/emacs-libvterm#369
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

2 participants