home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit 6e6635b543079d91f26189b96a1d2dce414d2d60
parent daf4a10b4827a69cd8e5b42ae7032abdcc05ef93
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Mon, 12 Sep 2022 14:51:58 +0200

tools/emacs: add and bind a "run in project vterm"…

… the idea is to be able to run command interactively on an
existing (or to-be-created) vterm shell. The goal is to easily be able
to run `gh pr create` for GitHub PRs for example.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mtools/emacs/config/config-projects.el | 17++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/emacs/config/config-projects.el b/tools/emacs/config/config-projects.el @@ -5,7 +5,8 @@ (use-package project :bind (("C-x p v" . vde-project-magit-status) - ("C-x p s" . vde-project-vterm)) + ("C-x p s" . vde-project-vterm) + ("C-x p X" . vde/run-in-project-vterm)) :config (setq vde/project-local-identifier '(".project")) ;; "go.mod" @@ -46,7 +47,7 @@ (interactive) (magit-status (vde-project--project-current))) - (defun vde-project-vterm () + (defun vde-project-vterm (&optional command) "Run `vterm' on project. If a buffer already exists for running a vterm shell in the project's root, switch to it. Otherwise, create a new vterm shell." @@ -60,7 +61,17 @@ switch to it. Otherwise, create a new vterm shell." (vterm default-project-vterm-name) (with-current-buffer vterm-buffer (vterm-send-string cd-cmd) - (vterm-send-return))))))) + (vterm-send-return)))) + (when command + (vterm-send-string command) + (vterm-send-return)))) + (defun vde/run-in-project-vterm () + (interactive) + (let* ((default-directory (vde-project--project-current)) + (default-project-vterm-name (project-prefixed-buffer-name "vterm")) + (vterm-buffer (get-buffer default-project-vterm-name))) + (vde-project-vterm (read-string "Command: ")))) + ) (provide 'config-projects) ;;; config-projects.el ends here