about summary refs log tree commit diff stats
path: root/bash/emacs.bash
blob: 3b7bb64680e926ae0fbb4cec50c40a7cab42bb25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Shell-side configuration for Emacs-based shells

setup_vterm() {
        ## https://github.com/akermu/emacs-libvterm#shell-side-configuration
        ## Make sure this is the last file loaded by ~/.bashrc!

        # Load the requisite code from the vterm install directory
        if [[ "$INSIDE_EMACS" = 'vterm' ]] \
                   && [[ -n ${EMACS_VTERM_PATH} ]] \
                   && [[ -f ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh ]]; then
                source ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh
        fi

        # Extra commands for `vterm-eval-cmds'
        find_file() { vterm_cmd find-file "$(realpath "${@:-.}")"; }
        say() { vterm_cmd message "%s" "$*"; }
}

setup_emacs_shell() {
        export PAGER=cat
        # export PS1='\w \$ '
}

# CONSIDER: Could this go in ~/.profile ?
case "$INSIDE_EMACS" in
        '') ;; # not inside emacs
        vterm) setup_vterm ;;
        *) setup_emacs_shell ;;
esac