complete-computing-environment/emacs_vterm.org

49 lines
1.6 KiB
Org Mode

:PROPERTIES:
:ID: 5cbfa8e8-e392-41aa-9ce6-462b80f29049
:ROAM_REFS: https://github.com/akermu/emacs-libvterm
:ROAM_ALIASES: vterm
:END:
#+TITLE: Emacs vterm Mode
#+filetags: :CCE:
#+ARCOLOGY_KEY: cce/vterm
#+ARCOLOGY_ALLOW_CRAWL: t
#+PROPERTY: header-args :mkdirp yes :results none
#+PROPERTY: header-args:emacs-lisp :tangle vterm.el
#+ARROYO_EMACS_MODULE: vterm
#+ARROYO_MODULE_WANTS: cce/configure_packaging.org
I like having this around but I'm not sure it's better than [[id:cce/emacs_shell_mode_is_good_enough][Shell-Mode]] until I can get [[id:cce/evil_mode][Evil Mode]] to work a bit better with it.
#+begin_src emacs-lisp
(use-package vterm
:config
(setq vterm-kill-buffer-on-exit nil
vterm-buffer-name-string "vterm<%s>"))
(provide 'cce/vterm)
#+end_src
Per the [[https://github.com/akermu/emacs-libvterm#shell-side-configuration][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.
#+begin_src shell :tangle bashrc.d/00-vterm-printf.sh
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)\]'
#+end_src