aboutsummaryrefslogtreecommitdiff
path: root/Emacs/.config/emacs/elisp/eshell-additions.el
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-06-13 00:55:25 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-06-13 00:56:08 +0100
commitf418d17001a72ee0cce8ac84dc5c56c919b0f98d (patch)
treeb704b960c0f268a71a2d6e15f470eb5e91260e2c /Emacs/.config/emacs/elisp/eshell-additions.el
parent6fa811691e751bf240427655911973552fd392dc (diff)
downloaddotfiles-f418d17001a72ee0cce8ac84dc5c56c919b0f98d.tar.gz
dotfiles-f418d17001a72ee0cce8ac84dc5c56c919b0f98d.tar.bz2
dotfiles-f418d17001a72ee0cce8ac84dc5c56c919b0f98d.zip
(Emacs/config|elisp)~rework Eshell
Now I have separate modules for the additional new functions I introduced for eshell and for the prompt function I made. Cleans up the configuration a bit and makes it easier to examine those files on their own, which I expect to grow.
Diffstat (limited to 'Emacs/.config/emacs/elisp/eshell-additions.el')
-rw-r--r--Emacs/.config/emacs/elisp/eshell-additions.el57
1 files changed, 57 insertions, 0 deletions
diff --git a/Emacs/.config/emacs/elisp/eshell-additions.el b/Emacs/.config/emacs/elisp/eshell-additions.el
new file mode 100644
index 0000000..94c948f
--- /dev/null
+++ b/Emacs/.config/emacs/elisp/eshell-additions.el
@@ -0,0 +1,57 @@
+;;; eshell-additions.el --- Some aliases for Eshell -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Aryadev Chavali
+
+;; Author: Aryadev Chavali <aryadev@aryadevchavali.com>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation version 2 of the License
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(autoload #'eshell/cd "eshell")
+(autoload #'eshell/echo "eshell")
+(autoload #'eshell/send-input "eshell")
+
+;; Aliases
+(defun eshell/goto (&rest args)
+ "Use `read-directory-name' to change directories"
+ (eshell/cd (list (read-directory-name "Directory?: "))))
+
+(defun eshell/project-root (&rest args)
+ "Change to directory `project-root'"
+ (if (project-current)
+ (eshell/cd (list (project-root (project-current))))
+ (let ((error-msg (propertize "Error" 'font-lock-face
+ '(:foreground "red"))))
+ (eshell/echo
+ (format "[%s]: No project in current directory" error-msg)))))
+
+;; Additional functions
+(defun +eshell/at-cwd ()
+ "Open an instance of eshell at the current working directory."
+ (interactive)
+ (let ((dir (if buffer-file-name
+ (file-name-directory buffer-file-name)
+ default-directory))
+ (buf (eshell)))
+ (with-current-buffer buf
+ (eshell/cd dir)
+ (eshell-send-input))))
+
+(provide 'eshell-additions)
+;;; eshell-additions.el ends here