Formed during work on projects, I need to:
- run docker-compose up
- access the database shell of the db service in docker-compose
- run mitmproxy
- run a new shell
Using org-babel of org-mode is a great solution (Literate Devops with Org-Mode
).
Therefore, this package provides a convenient interface for accessing those tasks instead of accessing org-mode files and executing org-babel code blocks.
- M-x
project-tasks
Find-file all files in `project-tasks-files`
-> get all src-blocks by `(org-babel-src-block-names)`
-> display src-blocks to user
-> user select and run `(org-babel-execute-src-block)`
(use-package project-tasks
:ensure t :defer t
:commands (project-tasks)
:init
;; Show project-tasks when switching projects
(add-to-list 'project-switch-commands '(project-tasks "tasks") t)
;; Add action to embark-file map
(with-eval-after-load 'embark
(define-key embark-file-map (kbd "P") #'project-tasks-in-dir))
:custom
;; Set the list of tasks files
(project-tasks-files '("tasks.org"))
;; Set the ignore files
;; (project-tasks-ignore-files '("README.org"))
;; Set the function to get current project dir
;; (project-tasks-root-func #'project-tasks-project-root)
;; Set the separator between file name and task name
;; (project-tasks-separator " -> ")
:config
(add-to-list 'marginalia-prompt-categories '("select task" . project-task))
(defvar-keymap embark-project-task-actions
:doc "Keymap for actions for project-task (when mentioned by name)."
:parent embark-general-map
"j" #'project-tasks-goto-task)
(add-to-list 'embark-keymap-alist '(project-task . embark-project-task-actions))
;; Bind project-tasks to project keymap
:bind
(:map project-prefix-map ("P" . project-tasks))
)
You need to ensure that your code blocks work as intended. This package serves as an interface for interacting with Org files but does not affect your Org configuration.
Declare some tasks in tasks.org
as below:
* Tasks
#+name: makemigrations
#+begin_src compile :name makemigrations
django-admin makemigrations
#+end_src
#+name: browser
#+begin_src compile :name browser
chromium --temp-profile http://localhost:8080
#+end_src
When you call M-x project-tasks
, it will display tasks that you want to choose to run
You can check more examples in tasks.org
file in this repository.