Translate from Bash → Emacs:
emacs
→ find-file
man
→ man
and call vterm-clear-scrollback
on clear
in Bash.
(with-eval-after-load 'vterm (setopt vterm-eval-cmds '(("find-file" find-file) ("man" man) ("vterm-clear-scrollback" vterm-clear-scrollback))))
# File `~/.bashrc-emacs', sourced from `~/.bashrc'. if test "$INSIDE_EMACS" == vterm then VTERM_COMMAND='\e]51;E' VTERM_COMMAND_END='\e\\' # Bridge `emacs' in Bash to 'find-file' in Emacs. emacs() { FILE="$(cd $(dirname "$1"); pwd)/$(basename "$1")" printf "${VTERM_COMMAND}" printf "find-file \"${FILE}\"" printf "${VTERM_COMMAND_END}" } # Bridge `man' in Bash to `man' in Emacs. man() { printf "${VTERM_COMMAND}" printf "man \"$1\"" printf "${VTERM_COMMAND_END}" } # Call 'vterm-clear-scrollback' in Emacs before 'clear' in Bash. clear() { printf "${VTERM_COMMAND}" printf "vterm-clear-scrollback" printf "${VTERM_COMMAND_END}" tput clear; } fi