From: Andreas Gerler Date: Sat, 17 Dec 2022 15:45:16 +0000 (+0100) Subject: configure vterm X-Git-Url: http://git.bundesbrandschatzamt.de/?a=commitdiff_plain;h=1ae6060e668fca90c2e32ad3696855f5f6a9a952;p=emacsconfig.git configure vterm Signed-off-by: Andreas Gerler --- diff --git a/bba-shell.org b/bba-shell.org index a98ec081..f93948c8 100644 --- a/bba-shell.org +++ b/bba-shell.org @@ -499,3 +499,53 @@ creating a /form/ that includes the filename. #+end_src The [[help:eshell-named-command][eshell-named-command]] takes the command separately from the arguments, so we use =car= and =cdr= on the form. + +* vterm +[2022-12-17 Sat 14:15] + +vterm can recognize the prompt and you can use c p and + c n to jump around. +For this we have to tweak the bash configuration a little bit. + +#+begin_src shell :eval never + if [ "$INSIDE_EMACS" == "vterm" ]; then + function vterm_printf() { + if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ]); then + # Tell tmux to pass the escape sequences through + 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 + } + + function vterm_prompt_end(){ + vterm_printf "51;A$(whoami)@$(hostname):$(pwd)" + } + fi + +#+end_src + +Additionally we have to modify the prompt: + +#+begin_src shell :eval never + if [ "$INSIDE_EMACS" == "vterm" ]; then + export PS1=$PS1'\[$(vterm_prompt_end)\]' + fi +#+end_src + +Usually I don't need f keys in the shell. +If necessary I can still prefix with q + +#+begin_src emacs-lisp + (defun bba-vterm-hook () + (define-key vterm-mode-map (kbd "") nil) + (define-key vterm-mode-map (kbd "S-") nil) + (define-key vterm-mode-map (kbd "") nil) + (define-key vterm-mode-map (kbd "S-") nil) + (define-key vterm-mode-map (kbd "") nil) + ) + (add-hook 'vterm-mode-hook 'bba-vterm-hook) +#+end_src