Compare commits

...

2 commits

Author SHA1 Message Date
389b0142a3 [emacs] Fish shell integration
Until it gets added for real
2026-03-11 12:49:51 +00:00
23f918c458 [emacs] Fix binding that got lost 2026-03-11 12:49:37 +00:00
4 changed files with 107 additions and 7 deletions

View file

@ -31,7 +31,11 @@ if test -d /home/linuxbrew/.linuxbrew
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv fish)"
end
if [ -n "$INSIDE_EMACS" ]
if [ -n "$EAT_SHELL_INTEGRATION_DIR" ]
source ~/.config/fish/eat.fish
else if [ -n "$INSIDE_EMACS" ]
# This is here to make emacs and ansi-term work properly; I'm not *quite*
# sure what it does but it's probably cool.
function fish_title

95
.config/fish/eat.fish Normal file
View file

@ -0,0 +1,95 @@
# integration/fish --- Fish integration
# Copyright (C) 2022-2024 Akib Azmain Turja.
# This file is not part of GNU Emacs.
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# For a full copy of the GNU General Public License
# see <https://www.gnu.org/licenses/>.
# Features missing compared to the bash/zsh integrations:
# - Fish history import into Emacs.
# - The PS2 prompt support (line continuation).
function eat_enable_integration
set -g __eat_integration_enabled yes
function __eat_chpwd --on-variable PWD
# Send the current working directory, for directory tracking.
printf '\e]51;e;A;%s;%s\e\\\\' \
"$(echo -n -- $hostname | base64)" \
"$(echo -n -- $PWD | base64)"
end
function __eat_preexec --on-event fish_preexec
set current_command $argv[1]
# Send current command.
printf '\e]51;e;F;%s\e\\\\' \
"$(echo -n -- $current_command | base64)"
# Send pre-exec sequence.
printf '\e]51;e;G\e\\\\'
# Update title to include the command running.
# "${PWD/$HOME/'~'}" converts "/home/akib/foo/" to "~/foo/".
# The next one is substituted with '$', or '#' if we're "root".
printf '\e]2;%s@%s:%s%s\e\\\\' "$USER" "$hostname" \
"$(string replace $HOME '~' $PWD)" \
"$(fish_is_root_user && echo '#' || echo '$')" \
"$current_command"
end
function __eat_postexec --on-event fish_postexec
set exit_status $status
# Send exit status.
printf '\e]51;e;H;%i\e\\\\' $exit_status
# Inform that a new prompt is going to be printed.
printf '\e]51;e;J\e\\\\'
# Update title.
# "${PWD/$HOME/'~'}" converts "/home/akib/org/" to "~/org/".
# The next one is substituted with '$', or '#' if we're "root".
printf '\e]2;%s@%s:%s%s\e\\\\' "$USER" "$hostname" \
"$(string replace $HOME '~' $PWD)" \
"$(fish_is_root_user && echo '#' || echo '$')"
end
functions --copy fish_prompt __eat_original_fish_prompt
function fish_prompt
printf '\e]51;e;B\e\\\\'
__eat_original_fish_prompt $argv
printf '\e]51;e;C\e\\\\'
end
end
function _eat_msg
set msg (printf '\e]51;e;M')
for arg in $argv
set msg $msg "$(echo -n -- $arg | base64)"
end
printf "%s\e\\\\" (string join ";" $msg)
end
if status is-interactive
and test -z $__eat_integration_enabled
and set -q EAT_SHELL_INTEGRATION_DIR
and string match -q "eat-*" $TERM
eat_enable_integration
end
# Local Variables:
# mode: fish
# End:

View file

@ -66,11 +66,11 @@
'(package-selected-packages
'(adaptive-wrap add-node-modules-path bazel blacken claudemacs clipetty
clojure-mode company dap-mode deadgrep doom-themes
earthfile-mode eglot-java filladapt fish-mode flycheck-elm
go-mode howm ink-mode jsonnet-mode magit poly-markdown
prettier-js protobuf-mode ron-mode rust-mode scala-ts-mode
sql-indent swift-mode terraform-mode typescript-mode
wgsl-mode xterm-color zig-mode))
earthfile-mode eat eglot-java filladapt fish-mode
flycheck-elm go-mode howm ink-mode jsonnet-mode magit
poly-markdown prettier-js protobuf-mode ron-mode rust-mode
scala-ts-mode sql-indent swift-mode terraform-mode
typescript-mode wgsl-mode xterm-color zig-mode))
'(package-vc-selected-packages '((claudemacs :url "https://github.com/cpoile/claudemacs")))
'(reb-re-syntax 'string)
'(rmail-mail-new-frame t)

View file

@ -1501,7 +1501,8 @@ Do this when you edit your project view."
;; =================================================================
;; Terminal
;; =================================================================
(use-package eat :ensure t)
(use-package eat :ensure t
:bind (("C-c T" . eat-project)))
;; =================================================================
;; ron-mode