;;; shell-config.el --- Shell and terminal configuration -*- lexical-binding: t -*-
;;; Commentary:
;; Configuration for shells, terminals, and related tools
;;; Code:
;; Eshell configuration
(use-package eshell
:bind ("M-/" . eshell)
:custom
(eshell-buffer-maximum-lines 10240)
(eshell-scroll-show-maximum-output t)
(eshell-scroll-to-bottom-on-input 'all)
(eshell-scroll-to-bottom-on-output 'all)
(eshell-where-to-jump 'begin)
(eshell-review-quick-commands nil)
(eshell-smart-space-goes-to-end t)
(eshell-hist-ignoredups t)
(eshell-cmpl-cycle-completions t)
(eshell-history-size 10000)
(eshell-status-in-mode-line nil)
:config
(setenv "EDITOR" "emacsclient")
(setenv "PAGER" "")
;; Set modules
(setq eshell-modules-list
'(eshell-alias
eshell-basic
eshell-cmpl
eshell-dirs
eshell-glob
eshell-hist
eshell-ls
eshell-pred
eshell-prompt
eshell-script
eshell-unix))
;; Set path - now uses exec-path
;; Define custom command to handle beginning of line
(defun eshell-maybe-bol ()
"Go to beginning of command line prompt, then to beginning of line."
(interactive)
(let ((p (point)))
(eshell-bol)
(when (= p (point))
(beginning-of-line))))
;; Eshell hook for customization
(defun dws/eshell-hook ()
"My eshell hook."
(define-key eshell-mode-map (kbd "C-a") 'eshell-maybe-bol)
(rename-buffer "*eshell*" t))
;; Add aliases
(defun eshell-add-aliases ()
"Add custom aliases to eshell."
(dolist (aliasvar '(("ff" "for i in ${eshell-flatten-list $*} {find-file $i}")
("fo" "find-file-other-window $1")
("fsl" "fossil $*")
("ll" "ls -l $*")
("ltr" "ls -ltr $*")))
(add-to-list 'eshell-command-aliases-list aliasvar)))
:hook
((eshell-mode . dws/eshell-hook)
(eshell-post-command . eshell-add-aliases)))
;; frequently used dirs with z
;; (use-package eshell-z
;; :after eshell
;; :ensure t
;; :hook (eshell-mode . eshell-z))
;; eat for visual commands
;; You'll need to 'tic -x ~/.emacs.d/elpa/eat-0.9.4/eat.ti
;; Version will obviously change over time
(use-package eat
:ensure t
:hook ((eshell-mode . eat-eshell-mode)))