0

I want my eshell to use ~/.bash_aliases. But it seems that it doesn't because my usual aliases do not work.

This is my full minimal config using use-package:

;; === Package setup ===
(require 'package)

(setq package-archives '(("melpa" . "https://melpa.org/packages/")
             ("elpa" . "https://elpa.gnu.org/packages/")))
;; Initializes the package infrastructure
(package-initialize)

;; === use-package ==
;; use-package to simplify the config file
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(require 'use-package)
(setq use-package-always-ensure 't)

;; ================
;; Terminal / Shell
;; ================
(defun efs/configure-eshell ()
  ;; Save command history when commands are entered
  (add-hook 'eshell-pre-command-hook 'eshell-save-some-history)
  ;; Disable highlite line mode
  (add-hook 'eshell-mode-hook (lambda ()
                (setq-local global-hl-line-mode nil)))
  ;; Truncate buffer for performance
  (add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer)

  (setq eshell-history-size         10000
        eshell-buffer-maximum-lines 10000
        eshell-hist-ignoredups t
        eshell-scroll-to-bottom-on-input t))

(use-package eshell-git-prompt)

(use-package eshell
  :config
  (with-eval-after-load 'esh-opt
    (setq eshell-destroy-buffer-when-process-dies t)
    (setq eshell-visual-commands '("htop", "bmon", "zsh", "vim", "tmux", "less")))
  (eshell-git-prompt-use-theme 'powerline)
  ;; This 5 lines are from another posting and should solve the problem
  ;; but they doesn't
  (setq explicite-shell-file-name "/bin/bash")
  (setq shell-file-name "bash")
  (setq explicit-bash.exe-args '("--noediting" "--login" "-ic"))
  (setq shell-command-switch "-ic")
  (setenv "SHELL" shell-file-name)
  :hook (eshell-first-time-mode . efs/configure-eshell)
  )

There is a similar question. The answer from there is still in my MWE but does not work.

buhtz
  • 679
  • 4
  • 22

2 Answers2

5

eshell should not use your bash aliases because, other than them both being shells, eshell has nothing to do with bash.

eshell is a shell written entirely in elisp. It's not bash, sh, ksh, csh, zsh, or any of the others, so it won't/shouldn't/can't process the config files for any of those shells.

If you want to use your bash config, you need to run bash. You can use M-x shell to run an external shell process in Emacs via comint.

For more information, see:

  • C-hig (emacs)Interactive Shell
  • C-hig (eshell)
phils
  • 48,657
  • 3
  • 76
  • 115
1

Eshell won't use bash aliases. As @phils mentioned, Eshell isn't a terminal emulator like bash et al.

When a command command is entered in Eshell it will first look for an Eshell alias with name command, then it will look for an Eshell built-in with the name command, next it will look for an Emacs function with name command. If none of the above work, your $PATH will be searched for a command of name command.

So, while bash aliases won't ever be looked for, a script in your $PATH will be sought and executed.

  • Eshell isn't a terminal emulator and neither is bash. What does that have to do with the question? – NickD Sep 01 '22 at 04:55