diff --git a/init.el b/init.el index c0f5086..26ce68f 100644 --- a/init.el +++ b/init.el @@ -422,6 +422,25 @@ (add-hook 'completion-at-point-functions '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. (use-package eat :ensure t