2014-02-12 18:31:00 +01:00
|
|
|
;; Eshell
|
2016-10-14 14:03:30 +02:00
|
|
|
|
2016-06-09 18:23:04 +02:00
|
|
|
;; This mode has a lot of hooks.
|
|
|
|
;; `emacs-load-hook' is run at the very beginning; not all variables/functions will be set.
|
|
|
|
;; `emacs-mode-hook' is run once everything is loaded.
|
2014-02-21 15:23:25 +01:00
|
|
|
|
2014-02-12 18:31:00 +01:00
|
|
|
(setq eshell-directory-name (concat emacs-cache-folder "eshell"))
|
2016-06-10 23:16:03 +02:00
|
|
|
|
|
|
|
;; Alias management possibilities:
|
|
|
|
;; - Version eshell-alias and store it in user-emacs-directory. Simplest and
|
|
|
|
;; fastest, but aliases cannot be included conditionnaly, e.g. depending on the
|
|
|
|
;; existence of a program.
|
|
|
|
;; - Store eshell-alias in cache and populate it dynamically on startup.
|
|
|
|
; (setq eshell-aliases-file (concat user-emacs-directory "eshell-alias"))
|
|
|
|
(setq eshell-prompt-function
|
|
|
|
(lambda nil
|
|
|
|
(let ((path (abbreviate-file-name (eshell/pwd))))
|
|
|
|
(concat ".-(" path ")"
|
|
|
|
(make-string (- (window-body-width) 5 (length path)) ?-)
|
|
|
|
"\n`--"
|
|
|
|
(if (= (user-uid) 0) "# " "> ")))))
|
|
|
|
;; If the prompt spans over multiple lines, the regexp should match last line only.
|
|
|
|
(setq eshell-prompt-regexp "^`--[#>] ")
|
2014-02-12 18:31:00 +01:00
|
|
|
|
2016-06-09 18:23:04 +02:00
|
|
|
(eval-after-load 'em-term
|
|
|
|
'(nconc eshell-visual-commands
|
2016-06-10 23:16:03 +02:00
|
|
|
'("abook" "cmus" "fzf" "htop" "mpv" "mutt" "ncdu" "newsbeuter" "ranger")))
|
|
|
|
; (eval-after-load 'em-term
|
|
|
|
; '(add-to-list 'eshell-visual-subcommands '("git" "log" "diff" "show")))
|
2016-06-09 18:23:04 +02:00
|
|
|
|
2016-06-10 23:16:03 +02:00
|
|
|
;; eshell/alias is too slow as it reads and write the file on each definition.
|
2016-06-09 18:23:04 +02:00
|
|
|
(eval-after-load 'em-alias
|
|
|
|
'(progn
|
2016-06-10 23:16:03 +02:00
|
|
|
(eshell-read-aliases-list)
|
|
|
|
(mapcar
|
|
|
|
(lambda (alias)
|
|
|
|
(add-to-list 'eshell-command-aliases-list alias))
|
|
|
|
'(("ls" "ls -F $*")
|
|
|
|
("l" "ls -1 $*")
|
|
|
|
("la" "ls -lAh $*")
|
|
|
|
("lc" "ls -ltcrh $*")
|
|
|
|
("lk" "ls -lSrh $*")
|
|
|
|
("ll" "ls -lh $*")
|
|
|
|
("lx" "ls -lXh $*")
|
|
|
|
("grep" "grep --color=auto")
|
|
|
|
("mkdir" "mkdir -p $*")
|
|
|
|
("mkcd" "mkdir -p $* && cd $1")
|
|
|
|
("emacs" "find-file $1")
|
|
|
|
("em" "find-file $1")))
|
|
|
|
(when (executable-find "/usr/bin/pacman")
|
|
|
|
(mapcar
|
|
|
|
(lambda (alias)
|
|
|
|
(add-to-list 'eshell-command-aliases-list alias))
|
|
|
|
'(("pc" "sudo pacman -Sc")
|
|
|
|
("pi" "sudo pacman -S --needed $*")
|
|
|
|
("pqi" "pacman -Qi $*")
|
|
|
|
("pqo" "pacman -Qo $*")
|
|
|
|
("pqs" "pacman -Qs $*")
|
|
|
|
("pr" "sudo pacman -Rs $*")
|
|
|
|
("psi" "pacman -Si $*")
|
|
|
|
("pss" "pacman -Ss $*")
|
2016-06-12 10:45:40 +02:00
|
|
|
("pu" "yes | sudo pacman -Sc && sudo pacman -Syu")
|
|
|
|
("pql" "pacman -Ql $* | /usr/bin/grep -v '/$'")
|
|
|
|
("pli" "expac -t '%F %T' '%-8l %n' | sort -rn | head -30")
|
|
|
|
("pacfiles" "pacman -Qlq ncdu | /usr/bin/grep -v '/$' | xargs du -cbh | sort -h"))))
|
2016-06-10 23:16:03 +02:00
|
|
|
(eshell-write-aliases-list)))
|
2014-02-12 18:31:00 +01:00
|
|
|
|
|
|
|
(provide 'mode-eshell)
|