(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
This commit is contained in:
3
Emacs/.config/emacs/.config/eshell/aliases
Normal file
3
Emacs/.config/emacs/.config/eshell/aliases
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
alias ff find-file-other-window $1
|
||||||
|
alias d dired $1
|
||||||
|
alias clear clear-scrollback
|
||||||
@@ -401,14 +401,13 @@ function to pull up the eshell quickly.
|
|||||||
(general-def
|
(general-def
|
||||||
:states '(normal insert)
|
:states '(normal insert)
|
||||||
:keymaps 'eshell-mode-map
|
:keymaps 'eshell-mode-map
|
||||||
"M-l" (proc (interactive) (eshell/clear)
|
"M-j" #'eshell-next-matching-input-from-input
|
||||||
"M-j" #'eshell-next-matching-input-from-input
|
"M-k" #'eshell-previous-matching-input-from-input)
|
||||||
"M-k" #'eshell-previous-matching-input-from-input)
|
(local-leader
|
||||||
(local-leader
|
:keymaps 'eshell-mode-map
|
||||||
:keymaps 'eshell-mode-map
|
"c" (proc (interactive) (eshell/clear)
|
||||||
"c" (proc (interactive) (eshell/clear)
|
(recenter))
|
||||||
(recenter))
|
"k" #'eshell-kill-process)))
|
||||||
"k" #'eshell-kill-process))))
|
|
||||||
:config
|
:config
|
||||||
(+oreo/create-toggle-function
|
(+oreo/create-toggle-function
|
||||||
+shell/toggle-eshell
|
+shell/toggle-eshell
|
||||||
@@ -430,7 +429,7 @@ Pretty symbols and a display record.
|
|||||||
:display
|
:display
|
||||||
("\\*e?shell\\*" ; for general shells as well
|
("\\*e?shell\\*" ; for general shells as well
|
||||||
(display-buffer-at-bottom)
|
(display-buffer-at-bottom)
|
||||||
(window-height . 0.25)))
|
(window-height . 0.40)))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Eshell variables and aliases
|
** Eshell variables and aliases
|
||||||
Set some sane defaults, a banner and a prompt. The prompt checks for
|
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
|
(use-package eshell
|
||||||
:config
|
:config
|
||||||
(defun +eshell/get-git-properties ()
|
(defun +eshell/get-git-properties ()
|
||||||
(let* ((git-branch (shell-command-to-string "git branch"))
|
(let ((git-branch (shell-command-to-string "git branch")))
|
||||||
(is-repo (string= (if (string= git-branch "") ""
|
(if (or (string= git-branch "")
|
||||||
(substring git-branch 0 1)) "*")))
|
(not (string= "*" (substring git-branch 0 1))))
|
||||||
(if (not is-repo) ""
|
""
|
||||||
(concat
|
(format
|
||||||
"("
|
"(%s<%s>)"
|
||||||
(nth 2 (split-string git-branch "\n\\|\\*\\| "))
|
(nth 2 (split-string git-branch "\n\\|\\*\\| "))
|
||||||
"<"
|
|
||||||
(if (string= "" (shell-command-to-string "git status | grep 'up to date'"))
|
(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
|
(setq eshell-cmpl-ignore-case t
|
||||||
eshell-cd-on-directory t
|
eshell-cd-on-directory t
|
||||||
eshell-banner-message (concat (shell-command-to-string "figlet eshell") "\n")
|
eshell-banner-message (concat (shell-command-to-string "fortune | cowsay") "\n")
|
||||||
eshell-prompt-function
|
eshell-highlight-prompt nil
|
||||||
(proc
|
eshell-prompt-function #'+eshell/prompt-function
|
||||||
(let ((properties (+eshell/get-git-properties)))
|
eshell-prompt-regexp "^𝜆> ")
|
||||||
(concat
|
|
||||||
properties
|
|
||||||
(format "[%s]\n" (abbreviate-file-name (eshell/pwd)))
|
|
||||||
"λ ")))
|
|
||||||
eshell-prompt-regexp "^λ ")
|
|
||||||
|
|
||||||
(defun eshell/goto (&rest args)
|
(defun eshell/goto (&rest args)
|
||||||
"Use `read-directory-name' to change directories."
|
"Use `read-directory-name' to change directories."
|
||||||
|
|||||||
Reference in New Issue
Block a user