Running Async Shell Commands with Projectile

In this quick tip post, I wanted to highlight a function from the projectile project that I have been using a lot lately.

If you are unfamiliar, projectile is one of the many useful @bbastov projects. It's aim is to provide functionality around working with projects in Emacs (e.g., finding a file within a project).

The function I have want to highlight is projectile-run-async-shell-command-in-root. As the name explains, it will asynchronously run a shell command from your projects current root (there is also a non-async version).

This function will prompt you for a shell command, open a split window, and print the output in the new window.

  • Because it's async it does not tie up Emacs like a synchronous command may
  • It does not require opening a term or shell split and cding to your projects root

I have found this most useful for small scripts we have in our projects at work. For example, we have a script to "setup" the project (pull in recent dependencies, perform database migrations, etc.). The ability to kick off these scripts and track their progress while optionally doing something else has been great.

As a Doom Emacs user (using Vim bindings), this command can be run with <SPC> p &.

Key Bindings
doom-leader-map p &
doom-leader-project-map &
general-override-mode-map <emacs-state> M-SPC p &
general-override-mode-map <insert-state> M-SPC p &
general-override-mode-map <motion-state> SPC p &
general-override-mode-map <normal-state> SPC p &
general-override-mode-map <visual-state> SPC p &
projectile-command-map &

Notice something wrong? Please consider proposing an edit or opening an issue.