commit d99ff8cbc0fdeec8744d644a6b7a4386e1e9e017
parent 148a8b5600823123d74a44491fdeecd82a3ec973
Author: dwrz <dwrz@dwrz.net>
Date: Tue, 27 Jun 2023 11:44:52 +0000
Refactor emacs C-x t keybinding to start shell
Diffstat:
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/emacs/init.el b/emacs/init.el
@@ -43,16 +43,20 @@
(when filename (kill-new filename)
(message "Copied buffer file name '%s' to the clipboard." filename))))
+(defun shell-in-current-directory ()
+ "Start a unique shell in the current directory."
+ (interactive)
+ (let ((default-directory (if (buffer-file-name)
+ (file-name-directory (buffer-file-name))
+ default-directory))
+ (shell-buffer-name "*shell*"))
+ (shell (generate-new-buffer-name shell-buffer-name))))
+
(defun dwrz-org-capture-at-point ()
"Insert an org capture template at point."
(interactive)
(org-capture 0))
-(defun dwrz-terminal ()
- "Start a terminal."
- (interactive)
- (start-process "terminal" nil "st"))
-
(defun dwrz-unfill-paragraph ()
"Unfill a paragraph."
(interactive)
@@ -572,5 +576,5 @@
(global-set-key (kbd "C-x b") 'ivy-switch-buffer)
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-x m") 'notmuch)
-(global-set-key (kbd "C-x t") 'dwrz-terminal)
+(global-set-key (kbd "C-x t") 'shell-in-current-directory)
(global-set-key (kbd "M-x") 'counsel-M-x)