aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to 'etc')
-rw-r--r--etc/emacs-vterm-bash.sh14
-rw-r--r--etc/emacs-vterm-zsh.sh14
-rw-r--r--etc/emacs-vterm.fish16
3 files changed, 43 insertions, 1 deletions
diff --git a/etc/emacs-vterm-bash.sh b/etc/emacs-vterm-bash.sh
index 395188b..15bf353 100644
--- a/etc/emacs-vterm-bash.sh
+++ b/etc/emacs-vterm-bash.sh
@@ -25,6 +25,20 @@ if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
}
fi
+# With vterm_cmd you can execute Emacs commands directly from the shell.
+# For example, vterm_cmd message "HI" will print "HI".
+# To enable new commands, you have to customize Emacs's variable
+# vterm-eval-cmds.
+vterm_cmd() {
+ local vterm_elisp
+ vterm_elisp=""
+ while [ $# -gt 0 ]; do
+ vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")"
+ shift
+ done
+ vterm_printf "51;E$vterm_elisp"
+}
+
# This is to change the title of the buffer based on information provided by the
# shell. See, http://tldp.org/HOWTO/Xterm-Title-4.html, for the meaning of the
# various symbols.
diff --git a/etc/emacs-vterm-zsh.sh b/etc/emacs-vterm-zsh.sh
index 7708cc2..b01f52d 100644
--- a/etc/emacs-vterm-zsh.sh
+++ b/etc/emacs-vterm-zsh.sh
@@ -22,6 +22,20 @@ if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
alias clear='vterm_printf "51;Evterm-clear-scrollback";tput clear'
fi
+# With vterm_cmd you can execute Emacs commands directly from the shell.
+# For example, vterm_cmd message "HI" will print "HI".
+# To enable new commands, you have to customize Emacs's variable
+# vterm-eval-cmds.
+vterm_cmd() {
+ local vterm_elisp
+ vterm_elisp=""
+ while [ $# -gt 0 ]; do
+ vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")"
+ shift
+ done
+ vterm_printf "51;E$vterm_elisp"
+}
+
# This is to change the title of the buffer based on information provided by the
# shell. See, http://tldp.org/HOWTO/Xterm-Title-4.html, for the meaning of the
# various symbols.
diff --git a/etc/emacs-vterm.fish b/etc/emacs-vterm.fish
index 6c9d205..25169a6 100644
--- a/etc/emacs-vterm.fish
+++ b/etc/emacs-vterm.fish
@@ -34,6 +34,18 @@ function fish_title
pwd
end
+# With vterm_cmd you can execute Emacs commands directly from the shell.
+# For example, vterm_cmd message "HI" will print "HI".
+# To enable new commands, you have to customize Emacs's variable
+# vterm-eval-cmds.
+function vterm_cmd --description 'Run an Emacs command among the ones defined in vterm-eval-cmds.'
+ set -l vterm_elisp ()
+ for arg in $argv
+ set -a vterm_elisp (printf '"%s" ' (string replace -a -r '([\\\\"])' '\\\\\\\\$1' $arg))
+ end
+ vterm_printf '51;E'(string join '' $vterm_elisp)
+end
+
# Sync directory and host in the shell with Emacs's current directory.
# You may need to manually specify the hostname instead of $(hostname) in case
# $(hostname) does not return the correct string to connect to the server.
@@ -43,7 +55,9 @@ end
function vterm_prompt_end;
vterm_printf '51;A'(whoami)'@'(hostname)':'(pwd)
end
-functions -c fish_prompt vterm_old_fish_prompt
+
+# We are going to add a portion to the prompt, so we copy the old one
+functions --copy fish_prompt vterm_old_fish_prompt
function fish_prompt --description 'Write out the prompt; do not replace this. Instead, put this at end of your file.'
# Remove the trailing newline from the original prompt. This is done