Bash aliases support

This commit is contained in:
Curt Spark 2026-03-01 23:39:07 +00:00
parent d0cc4ec8d3
commit 3a99cd3660
1 changed files with 19 additions and 0 deletions

19
init.el
View File

@ -422,6 +422,25 @@
(add-hook 'completion-at-point-functions (add-hook 'completion-at-point-functions
'bash-completion-capf-nonexclusive nil t))) 'bash-completion-capf-nonexclusive nil t)))
) )
; Import bash aliases to eshell
(defun eshell-load-bash-aliases ()
"Read Bash aliases and add them to the list of eshell aliases."
;; Bash needs to be run - temporarily - interactively
;; in order to get the list of aliases.
(with-temp-buffer
(call-process "bash" nil '(t nil) nil "-ci" "alias")
(goto-char (point-min))
; Bash aliases to exclude
(flush-lines "^alias magit\\|^alias oc\\|^alias z\\|^alias zi\\|^alias cd\\|^alias cdi\\|^alias sudo")
(while (re-search-forward "alias \\(.+\\)='\\(.+\\)'$" nil t)
(add-to-list 'eshell-command-aliases-list (list (match-string 1) (match-string 2))))))
;; We only want Bash aliases to be loaded when Eshell loads its own aliases,
;; rather than every time `eshell-mode' is enabled.
(add-hook 'eshell-first-time-mode-hook 'eshell-load-bash-aliases t)
; Eat is a terminal emulator that can integrate nicely with eshell, allows us to run full ncurses applications inside eshell. ; Eat is a terminal emulator that can integrate nicely with eshell, allows us to run full ncurses applications inside eshell.
(use-package eat (use-package eat
:ensure t :ensure t