This package allows running a shell command in a buffer and provides conveniences for creating and managing these buffers. This is essentially an alternative to the built in compile
command.
(Sorry about the dithering in the screenshots. It’s something that Github is doing and I’m not totally sure why.)
async-launch-shell
starts a new buffer with a command read from the minibuffer.
Once you have an async-shell
buffer, you can rerun the command by calling revert-buffer
.
Pinning a line number (<async-shell-menu> p
): When working on code, I often find it useful to pin the output to a certain line, so that I don’t have to scroll and find a particular location every time I rerun a command.
Re-run on save (<async-shell-menu> r
): Enabling Reload on save
will re-run the command in that buffer every time a file is saved. I find this incredibly useful for debugging code.
You can also create async-shell
buffers from org-babel
.
#+begin_src async-shell :name gif :results silent
name="babel"
ffmpeg -y -i ~/Desktop/$name.mov \
-pix_fmt rgb24 -r 10 \
pictures/$name.gif
gifsicle -O3 pictures/$name.gif -o pictures/$name.gif
#+end_src
This is useful for keeping track of and executing complex commands that you need to execute for different projects. Many of my projects contain an org-file where I can write down different commands I execute on a regular basis and add documentation explaining what they do. This means that I never have to search back through my command history to find a particular command, and makes editing commands trivial.
Additionally, async-shell
babel blocks support specifying tramp directories. If I wanted to run the above command on some server, I could write:
#+begin_src async-shell :name gif :results silent :dir /ssh:[email protected]:some/path
name="reload-on-save"
ffmpeg -y -i ~/Desktop/$name.mov \
-pix_fmt rgb8 -r 10 \
pictures/$name.gif
gifsicle -O3 pictures/$name.gif -o pictures/$name.gif
#+end_src
To support async-shell
blocks, all you need to do is add (async-shell . t)
to your 'org-babel-load-languages
.
(org-babel-do-load-languages
'org-babel-load-languages
'((async-shell . t)
...))