complete-computing-environment/emacs_vterm.org

1.6 KiB

Emacs vterm Mode

I like having this around but I'm not sure it's better than Shell-Mode until I can get Evil Mode to work a bit better with it.

(use-package vterm
  :config
  (setq vterm-kill-buffer-on-exit nil
        vterm-buffer-name-string "vterm<%s>"))
(provide 'cce/vterm)

Per the vterm README's Shell Side Configuration, some helper code which is used to signal vterm, as well as help it find the ends of prompts.

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)\]'