config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

commit cbf7fd2c82dd7eeaca1fbda3f6e6a40c098ce172
parent 3afb4b528d2371cd79301145c50ac391a512737f
Author: dwrz <dwrz@dwrz.net>
Date:   Sat,  8 Jul 2023 22:50:53 +0000

Refactor shell-in-current-directory

Diffstat:
Memacs/init.el | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/emacs/init.el b/emacs/init.el @@ -44,14 +44,17 @@ (message "Copied buffer file name '%s' to the clipboard." filename)))) (defun shell-in-current-directory () - "Start a unique shell in the current directory." + "Create or switch to a shell buffer for the current directory." (interactive) (let* ((default-directory (if (buffer-file-name) - (file-name-directory (buffer-file-name)) - default-directory)) + (file-name-directory (buffer-file-name)) + default-directory)) (dir-path (expand-file-name default-directory)) - (shell-buffer-name (concat "*shell:" dir-path "*"))) - (shell (generate-new-buffer-name shell-buffer-name)))) + (shell-buffer-name (concat "*shell:" dir-path "*")) + (existing-shell-buffer (get-buffer shell-buffer-name))) + (if existing-shell-buffer + (switch-to-buffer existing-shell-buffer) + (shell (generate-new-buffer-name shell-buffer-name))))) (defun dwrz-org-capture-at-point () "Insert an org capture template at point."