Add shell integration script for GNU Bash
* integration/bash: New file. * eat.el (eat-term-shell-integration-directory): New variable. Contains path to the directory containing the scripts, automatically updated when Eat is updated. * eat.el (eat-exec, eat-eshell-mode): New enviroment variable 'EAT_SHELL_INTEGRATION_DIR'. * eat.texi (Shell Integration): New chapter. * eat.texi (Directory Tracking): Refer to 'Shell Integration'.
This commit is contained in:
parent
5f4f4a87d1
commit
d918dbae87
3 changed files with 54 additions and 7 deletions
24
eat.el
24
eat.el
|
@ -255,6 +255,7 @@ This value is used by terminal programs to identify the terminal."
|
||||||
"Path to directory where Eat is installed.")
|
"Path to directory where Eat is installed.")
|
||||||
|
|
||||||
(defvar eat-term-terminfo-directory)
|
(defvar eat-term-terminfo-directory)
|
||||||
|
(defvar eat-term-shell-integration-directory)
|
||||||
(let ((old-install-path eat--install-path))
|
(let ((old-install-path eat--install-path))
|
||||||
(setq eat--install-path
|
(setq eat--install-path
|
||||||
(copy-sequence
|
(copy-sequence
|
||||||
|
@ -262,15 +263,27 @@ This value is used by terminal programs to identify the terminal."
|
||||||
buffer-file-name))))
|
buffer-file-name))))
|
||||||
|
|
||||||
(defcustom eat-term-terminfo-directory eat--install-path
|
(defcustom eat-term-terminfo-directory eat--install-path
|
||||||
"Directory where require terminfo databases can be found.
|
"Directory where required terminfo databases can be found.
|
||||||
|
|
||||||
This value is used by terminal programs to find the terminfo databases
|
This value is used by terminal programs to find the terminfo databases
|
||||||
that describe the capabilities of the terminal."
|
that describe the capabilities of the terminal."
|
||||||
:type 'directory
|
:type 'directory
|
||||||
:group 'eat-term)
|
:group 'eat-term)
|
||||||
|
|
||||||
|
(defcustom eat-term-shell-integration-directory
|
||||||
|
(expand-file-name "integration" eat--install-path)
|
||||||
|
"Directory where Eat shell integration scripts can be found.
|
||||||
|
|
||||||
|
This value is exposed to terminal programs as
|
||||||
|
`EAT_SHELL_INTEGRATION_DIR' environment variable."
|
||||||
|
:type 'directory
|
||||||
|
:group 'eat-ui
|
||||||
|
:group 'eat-eshell)
|
||||||
|
|
||||||
(when (eq eat-term-terminfo-directory old-install-path)
|
(when (eq eat-term-terminfo-directory old-install-path)
|
||||||
(setq eat-term-terminfo-directory eat--install-path)))
|
(setq eat-term-terminfo-directory eat--install-path
|
||||||
|
eat-term-shell-integration-directory
|
||||||
|
(expand-file-name "integration" eat--install-path))))
|
||||||
|
|
||||||
(defcustom eat-term-inside-emacs (format "%s,eat" emacs-version)
|
(defcustom eat-term-inside-emacs (format "%s,eat" emacs-version)
|
||||||
"Value for the `INSIDE_EMACS' environment variable."
|
"Value for the `INSIDE_EMACS' environment variable."
|
||||||
|
@ -2212,7 +2225,6 @@ MODE should be one of nil and `x10', `normal', `button-event',
|
||||||
|
|
||||||
URL should be a URL in the format \"file://HOST/CWD/\"; HOST can be
|
URL should be a URL in the format \"file://HOST/CWD/\"; HOST can be
|
||||||
empty."
|
empty."
|
||||||
(message "%S" url)
|
|
||||||
(let ((obj (url-generic-parse-url url)))
|
(let ((obj (url-generic-parse-url url)))
|
||||||
(when (and (string= (url-type obj) "file")
|
(when (and (string= (url-type obj) "file")
|
||||||
(or (null (url-host obj))
|
(or (null (url-host obj))
|
||||||
|
@ -4563,7 +4575,9 @@ same Eat buffer. The hook `eat-exec-hook' is run after each exec."
|
||||||
(list
|
(list
|
||||||
(concat "TERM=" (eat-term-name))
|
(concat "TERM=" (eat-term-name))
|
||||||
(concat "TERMINFO=" eat-term-terminfo-directory)
|
(concat "TERMINFO=" eat-term-terminfo-directory)
|
||||||
(concat "INSIDE_EMACS=" eat-term-inside-emacs))
|
(concat "INSIDE_EMACS=" eat-term-inside-emacs)
|
||||||
|
(concat "EAT_SHELL_INTEGRATION_DIR="
|
||||||
|
eat-term-shell-integration-directory))
|
||||||
process-environment))
|
process-environment))
|
||||||
(process-connection-type t)
|
(process-connection-type t)
|
||||||
;; We should suppress conversion of end-of-line format.
|
;; We should suppress conversion of end-of-line format.
|
||||||
|
@ -5103,6 +5117,8 @@ sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
|
||||||
`(("TERM" eat--eshell-term-name t)
|
`(("TERM" eat--eshell-term-name t)
|
||||||
("TERMINFO" eat-term-terminfo-directory t)
|
("TERMINFO" eat-term-terminfo-directory t)
|
||||||
("INSIDE_EMACS" eat-term-inside-emacs t)
|
("INSIDE_EMACS" eat-term-inside-emacs t)
|
||||||
|
("EAT_SHELL_INTEGRATION_DIR"
|
||||||
|
eat-term-shell-integration-directory t)
|
||||||
,@eshell-variable-aliases-list))
|
,@eshell-variable-aliases-list))
|
||||||
(advice-add #'eshell-gather-process-output :around
|
(advice-add #'eshell-gather-process-output :around
|
||||||
#'eat--eshell-adjust-make-process-args))
|
#'eat--eshell-adjust-make-process-args))
|
||||||
|
|
26
eat.texi
26
eat.texi
|
@ -71,6 +71,7 @@ Advanced Customizations
|
||||||
* Mouse Tracking:: Eat tracks mouse, but this can be changed.
|
* Mouse Tracking:: Eat tracks mouse, but this can be changed.
|
||||||
* Clipboard:: Integrating kill ring with terminal.
|
* Clipboard:: Integrating kill ring with terminal.
|
||||||
* Directory Tracking:: Tracking the working directory of program.
|
* Directory Tracking:: Tracking the working directory of program.
|
||||||
|
* Shell Integration:: Getting the most from Eat and your shell.
|
||||||
* Colors:: Eat can show more than sixteen million colors.
|
* Colors:: Eat can show more than sixteen million colors.
|
||||||
* Fonts:: Eat can show up to sixty font different fonts.
|
* Fonts:: Eat can show up to sixty font different fonts.
|
||||||
* Blinking Text:: Annoying blinking texts.
|
* Blinking Text:: Annoying blinking texts.
|
||||||
|
@ -486,9 +487,10 @@ directory is changed back to the directory from where the program was
|
||||||
invoked.
|
invoked.
|
||||||
|
|
||||||
To track, Eat needs the program to send this information. So, to
|
To track, Eat needs the program to send this information. So, to
|
||||||
enable directory tracking, you'll need to setup your shell. You'll
|
enable directory tracking, you'll need to setup your shell
|
||||||
need to arrange that your shell sends appropriate escape sequence at
|
(@pxref{Shell Integration}). You'll need to arrange that your shell
|
||||||
each prompt, for example with the command:
|
sends appropriate escape sequence at each prompt, for example with the
|
||||||
|
command:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
printf "\\e]7;file://%s%s\\e\\\\" "$HOSTNAME" "$PWD"
|
printf "\\e]7;file://%s%s\\e\\\\" "$HOSTNAME" "$PWD"
|
||||||
|
@ -503,6 +505,24 @@ This controls directory tracking. When set to non-@code{nil}, Eat
|
||||||
tracks the current working directory of programs.
|
tracks the current working directory of programs.
|
||||||
@end defopt
|
@end defopt
|
||||||
|
|
||||||
|
@node Shell Integration
|
||||||
|
@cindex shell integration
|
||||||
|
@cindex integration, shell
|
||||||
|
@chapter Shell Integration
|
||||||
|
|
||||||
|
Eat comes with shell scripts to integrate your favorite shell with
|
||||||
|
Eat. You can include the script in your shell configuration file,
|
||||||
|
it'll take care of everything.
|
||||||
|
|
||||||
|
Currently only GNU Bash is supported.
|
||||||
|
|
||||||
|
If you use GNU Bash, put the following in your @samp{.bashrc} file:
|
||||||
|
|
||||||
|
@example
|
||||||
|
[ -n "$EAT_SHELL_INTEGRATION_DIR" ] && \
|
||||||
|
source "$EAT_SHELL_INTEGRATION_DIR/bash"
|
||||||
|
@end example
|
||||||
|
|
||||||
@node Colors
|
@node Colors
|
||||||
@cindex colors
|
@cindex colors
|
||||||
@cindex customizing colors
|
@cindex customizing colors
|
||||||
|
|
11
integration/bash
Normal file
11
integration/bash
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
function _eat_prompt_command () {
|
||||||
|
# Send the current working directory, for directory tracking.
|
||||||
|
printf "\\e]7;file://%s%s\\e\\\\" "$HOSTNAME" "$PWD"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add '_eat_prompt_command' as the last element of 'PROMPT_COMMAND'.
|
||||||
|
PROMPT_COMMAND[${#PROMPT_COMMAND[*]}]=_eat_prompt_command
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: sh
|
||||||
|
# End:
|
Loading…
Add table
Reference in a new issue