Index Emagician Base Install Meta Interface Programming Text Org Lamp Journal Snippets jonnay.netFork on Github

Eshell Magick

Table of Contents

1 About the name…

If this file is called eshell.org, it weaves into eshell.el, and then require gets problematic.

(add-hook 'emacs-startup-hook 'eshell)

2 Fixes

2.1 Jigger path so that jamf won't break shit

jamf adds a symlink to the path, which makes completion barf when starting eshell.

¯\(ツ)_/¯

So we will jiggery poke the path.

(setenv "PATH"
        (replace-regexp-in-string ":/usr/local/bin/jamf"
                                                ""
                                                (getenv "PATH")))

2.2 Execute an eshell Command Programmatically Thank you wasamasa

(defun emagician/eshell-command (cmd) 
  (with-current-buffer "*eshell*"
     (eshell-return-to-prompt)
     (insert cmd)
     (eshell-send-input)))

2.3 Use helm for history

(use-package eshell
  :demand 
  :bind (:map eshell-mode-map
         ("M-S-r" . helm-eshell-history)))

2.4 Fix an issue with running commands remotely through tramp

http://emacs.stackexchange.com/questions/2107/run-application-in-cwd-on-remote-host-from-within-eshell

This is apparently still an issue.

(defadvice eshell-gather-process-output (before absolute-cmd (command args) act)
  (setq command (file-truename command)))

(add-to-list 'tramp-remote-path 'tramp-own-remote-path)

2.5 Pager 😻

Use cat as a pager. Fixes all kinds of things.

(setenv "PAGER" "cat")

3 Interface

3.1 Set Prompt

(use-package eshell-prompt-extras
  :init
  (setq eshell-highlight-prompt nil
        eshell-prompt-function 'emagician/epe-theme))

3.2 Use my own theme

(defun emagician/epe-theme ()
  "Emagician Eshell Prompt Extras theme."
  (setq eshell-prompt-regexp "^[^#\n🐰]*[#🐰]) ")
  (concat
   "\n"
   (epe-colorize-with-face "\n" 'mode-line)
   (when (epe-remote-p)
     (epe-colorize-with-face "[ Remote ]"
                             'epe-remote-face))
   (epe-colorize-with-face (eshell/pwd) 'epe-dir-face)
   (when (epe-git-p)
     (concat
      (epe-colorize-with-face ":" 'epe-dir-face)
      (epe-colorize-with-face
       (concat (epe-git-branch)
               (epe-git-dirty)
               (epe-git-untracked)
               (let ((unpushed (epe-git-unpushed-number)))
                 (unless (= unpushed 0)
                   (concat ":" (number-to-string unpushed)))))
       'epe-git-face)))
   (epe-colorize-with-face "\n 🐰)" 'epe-symbol-face)
   (epe-colorize-with-face (if (= (user-uid) 0) "#" "") 'epe-sudo-symbol-face)
   " "))

3.3 Did you mean?

(use-package eshell-did-you-mean 
  :demand
  :config
  (eshell-did-you-mean-setup))

3.4 Show fringe

(use-package eshell-fringe-status
  :init
  (add-hook 'eshell-mode-hook 'eshell-fringe-status-mode))

Footnotes:

1

Thank you wasamasa

Author: Jonathan Arkell

Created: 2018-05-18 Fri 10:30

Validate