Rudolf Adamkovič Personal site


Custom commands

Translate from Bash → Emacs:

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

© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.