From 2ddb3bd2ef49be54baf5dcbdccf8caa8efb46d3d Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 14 Oct 2023 21:44:36 +0100 Subject: (Emacs/app)~clean up and extend eshell configuration + Eshell prompt has nice colours now instead of just the flat blue ~ Generally cleaned up the configuration + Eshell aliases into version control --- Emacs/.config/emacs/.config/eshell/aliases | 3 ++ Emacs/.config/emacs/app.org | 71 ++++++++++++++++++------------ 2 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 Emacs/.config/emacs/.config/eshell/aliases (limited to 'Emacs/.config/emacs') diff --git a/Emacs/.config/emacs/.config/eshell/aliases b/Emacs/.config/emacs/.config/eshell/aliases new file mode 100644 index 0000000..17fa780 --- /dev/null +++ b/Emacs/.config/emacs/.config/eshell/aliases @@ -0,0 +1,3 @@ +alias ff find-file-other-window $1 +alias d dired $1 +alias clear clear-scrollback \ No newline at end of file diff --git a/Emacs/.config/emacs/app.org b/Emacs/.config/emacs/app.org index f4382bb..01c24d7 100644 --- a/Emacs/.config/emacs/app.org +++ b/Emacs/.config/emacs/app.org @@ -401,14 +401,13 @@ function to pull up the eshell quickly. (general-def :states '(normal insert) :keymaps 'eshell-mode-map - "M-l" (proc (interactive) (eshell/clear) - "M-j" #'eshell-next-matching-input-from-input - "M-k" #'eshell-previous-matching-input-from-input) - (local-leader - :keymaps 'eshell-mode-map - "c" (proc (interactive) (eshell/clear) - (recenter)) - "k" #'eshell-kill-process)))) + "M-j" #'eshell-next-matching-input-from-input + "M-k" #'eshell-previous-matching-input-from-input) + (local-leader + :keymaps 'eshell-mode-map + "c" (proc (interactive) (eshell/clear) + (recenter)) + "k" #'eshell-kill-process))) :config (+oreo/create-toggle-function +shell/toggle-eshell @@ -430,7 +429,7 @@ Pretty symbols and a display record. :display ("\\*e?shell\\*" ; for general shells as well (display-buffer-at-bottom) - (window-height . 0.25))) + (window-height . 0.40))) #+end_src ** Eshell variables and aliases Set some sane defaults, a banner and a prompt. The prompt checks for @@ -447,29 +446,45 @@ much faster than ~cd ..; ls -l~). (use-package eshell :config (defun +eshell/get-git-properties () - (let* ((git-branch (shell-command-to-string "git branch")) - (is-repo (string= (if (string= git-branch "") "" - (substring git-branch 0 1)) "*"))) - (if (not is-repo) "" - (concat - "(" + (let ((git-branch (shell-command-to-string "git branch"))) + (if (or (string= git-branch "") + (not (string= "*" (substring git-branch 0 1)))) + "" + (format + "(%s<%s>)" (nth 2 (split-string git-branch "\n\\|\\*\\| ")) - "<" (if (string= "" (shell-command-to-string "git status | grep 'up to date'")) - "×" - "✓") - ">)")))) + (propertize "×" 'font-lock-face '(:foreground "red")) + (propertize "✓" 'font-lock-face '(:foreground "green"))))))) + (defun +eshell/prompt-function () + (let ((git (+eshell/get-git-properties))) + (mapconcat + (lambda (item) + (if (listp item) + (propertize (car item) + 'read-only t + 'font-lock-face (cdr item) + 'front-sticky '(font-lock-face read-only) + 'rear-nonsticky '(font-lock-face read-only)) + item)) + (list + '("[") + `(,(abbreviate-file-name (eshell/pwd)) :foreground "LimeGreen") + '("]") + (if (string= git "") + "" + (concat "-" git "")) + "\n" + `(,(format-time-string "[%H:%M:%S]") :foreground "purple") + "\n" + '("𝜆> " :foreground "DeepSkyBlue"))))) + (setq eshell-cmpl-ignore-case t eshell-cd-on-directory t - eshell-banner-message (concat (shell-command-to-string "figlet eshell") "\n") - eshell-prompt-function - (proc - (let ((properties (+eshell/get-git-properties))) - (concat - properties - (format "[%s]\n" (abbreviate-file-name (eshell/pwd))) - "λ "))) - eshell-prompt-regexp "^λ ") + eshell-banner-message (concat (shell-command-to-string "fortune | cowsay") "\n") + eshell-highlight-prompt nil + eshell-prompt-function #'+eshell/prompt-function + eshell-prompt-regexp "^𝜆> ") (defun eshell/goto (&rest args) "Use `read-directory-name' to change directories." -- cgit v1.2.3-13-gbd6f