diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-06-03 00:34:19 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-06-03 00:34:19 +0100 |
commit | 4cabfc0c8f91332da2d1cc4f10b4d8a5dd637606 (patch) | |
tree | c745772d53454efca0bf07a27a507bfde5a52459 /Emacs/.config/emacs/elisp/eshell-additions.el | |
parent | a60e03f7976177fa3b06528fe754f7e62a604cc9 (diff) | |
download | dotfiles-4cabfc0c8f91332da2d1cc4f10b4d8a5dd637606.tar.gz dotfiles-4cabfc0c8f91332da2d1cc4f10b4d8a5dd637606.tar.bz2 dotfiles-4cabfc0c8f91332da2d1cc4f10b4d8a5dd637606.zip |
Updates, loads of updates!
Diffstat (limited to 'Emacs/.config/emacs/elisp/eshell-additions.el')
-rw-r--r-- | Emacs/.config/emacs/elisp/eshell-additions.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Emacs/.config/emacs/elisp/eshell-additions.el b/Emacs/.config/emacs/elisp/eshell-additions.el index a9362db..2d53610 100644 --- a/Emacs/.config/emacs/elisp/eshell-additions.el +++ b/Emacs/.config/emacs/elisp/eshell-additions.el @@ -41,14 +41,23 @@ "Change to directory `project-root'" (if (project-current) (eshell/cd (list (project-root (project-current)))) + (setq eshell-last-command-status 1) (eshell/echo (format "[%s]: No project in current directory" (propertize "Error" 'font-lock-face '(:foreground "red")))))) (defun eshell/sudo-switch (&rest args) - "Switch to a tramp connection sudo in the current directory" - (let ((wrapped-dir (concat "/sudo::" default-directory))) - (eshell/cd wrapped-dir))) + "Switch to and from administrative (sudo) mode in Eshell. +Uses tramp to figure out if we're in sudo mode or not. " + (let ((user (file-remote-p default-directory 'user))) + (cond + ((null user) + (let ((wrapped-dir (concat "/sudo::" default-directory))) + (eshell/cd wrapped-dir))) + ((string= user "root") + (thread-last 'localname + (file-remote-p default-directory) + eshell/cd))))) ;; Additional functions (defun +eshell/at-cwd (&optional arg) |