diff options
| author | bard <[email protected]> | 2023-12-20 06:13:47 -0500 |
|---|---|---|
| committer | bard <[email protected]> | 2023-12-20 06:13:47 -0500 |
| commit | b038d13fa42a9b29b08a13d554a7a5f8b7987f65 (patch) | |
| tree | b945f4d3812ebacef637934e57bcaf6c5132a188 | |
| parent | f22310f8323bee542bcae82faaea9c328cd8ee45 (diff) | |
eshell support
| -rw-r--r-- | bard-elisp/bard-eshell.el | 54 | ||||
| -rw-r--r-- | bard-emacs-modules/bard-emacs-package.el | 5 |
2 files changed, 59 insertions, 0 deletions
diff --git a/bard-elisp/bard-eshell.el b/bard-elisp/bard-eshell.el new file mode 100644 index 0000000..dd255c8 --- /dev/null +++ b/bard-elisp/bard-eshell.el @@ -0,0 +1,54 @@ +(require 'cl-lib) + +(defun bard/eshell-complete-recent-dir (&optional args) + "Switch to a recent `eshell` directory using completion" + (interactive "P") + (let* ((dirs (ring-elements eshell-last-dir-ring)) + (dir (vertico--exhibit () + (completing-read "Switch to recent dir: " dirs nil t)))) + (insert-dir) + (eshell-send-input) + (when arg + (dired-dir)))) + +(defun bard/eshell-find-file-at-point () + "Run `find-file` to find file" + (interactive) + (let ((file (ffap-file-at-point))) + (if file + (find-file file) + (user-error "No file at point")))) + +;; (defun bard/eshell-narrow-output-highlight-regexp () +;; (interactive) +;; (let ((regexp (read-regexp "Regexp to highlight: "))) +;; (narrow-to-region (eshell-beginning-of-output) +;; (eshell-end-of-output)) +;; (goto-char (point-min)) +;; (highlight-regexp regexp 'hi-yellow))) + + +(defun select-or-create (arg) + "Commentary ARG." + (if (string= arg "New eshell") + (eshell t) + (switch-to-buffer arg))) + (defun eshell-switcher (&optional arg) + "Commentary ARG." + (interactive) + (let* ( + (buffers (cl-remove-if-not (lambda (n) (eq (buffer-local-value 'major-mode n) 'eshell-mode)) (buffer-list)) ) + (names (mapcar (lambda (n) (buffer-name n)) buffers)) + (num-buffers (length buffers) ) + (in-eshellp (eq major-mode 'eshell-mode))) + (cond ((eq num-buffers 0) (eshell (or arg t))) + ((not in-eshellp) (switch-to-buffer (car buffers))) + (t (select-or-create (completing-read "Select Shell:" (cons "New eshell" names))))))) + +(define-key eshell-mode-map (kbd "C-c f") #'bard/eshell-find-file-at-point) +;; (define-key eshell-mode-map (kbd "C-c h") #'bard/eshell-narrow-ouput-highlight-regexp) +(define-key eshell-mode-map (kbd "C-c d") #'bard/eshell-complete-recent-dir) +(define-key eshell-mode-map (kbd "M-k") #'eshell-kill-input) +(global-set-key (kbd "C-z") nil) + +(define-key global-map (kbd "C-z e") #'eshell-switcher) diff --git a/bard-emacs-modules/bard-emacs-package.el b/bard-emacs-modules/bard-emacs-package.el index 69247b1..1a6c865 100644 --- a/bard-emacs-modules/bard-emacs-package.el +++ b/bard-emacs-modules/bard-emacs-package.el @@ -357,4 +357,9 @@ (diminish 'eldoc-mode) (diminish 'company-mode)) +(use-package eshell-git-prompt + :ensure t + :config + (eshell-git-prompt-use-theme 'robbyrussell)) + (provide 'bard-emacs-package.el) |
