The pal package's prompt directory is a directory of markdown files that
is automatically registered with the pal package on package load.
directory_*()
functions allow users to interface with the directory,
making new "roles" available:
directory_path()
returns the path to the prompt directory, which defaults to~/.config/pal
.directory_set()
changes the path to the prompt directory (by setting the option.pal_dir
).directory_list()
enumerates all of the different prompts that currently live in the directory (and provides clickable links to each).directory_load()
registers each of the prompts in the prompt directory with the pal package (via.pal_add()
).
Functions prefixed with prompt*()
allow users to conveniently create, edit,
and delete the prompts in pal's prompt directory.
Format of the prompt directory
Prompts are markdown files with the
name role-interface.md
, where interface is one of
"replace", "prefix" or "suffix".
An example directory might look like:
In that case, pal will register two custom pals when you call library(pal)
.
One of them has the role "proofread" and will replace the selected text with
a proofread version (according to the instructions contained in the markdown
file itself). The other has the role "summarize" and will prefix the selected
text with a summarized version (again, according to the markdown file's
instructions). Note:
Files without a
.md
extension are ignored.Files with a
.md
extension must contain only one hyphen in their filename, and the text following the hyphen must be one ofreplace
,prefix
, orsuffix
.
To load custom prompts every time the package is loaded, place your
prompts in directory_path()
. To change the prompt directory without
loading the package, just set the .pal_dir
option with
options(.pal_dir = some_dir)
. To load a directory of files that's not
the prompt directory, provide a dir
argument to directory_load()
.
See also
The "Custom pals" vignette, at vignette("custom", package = "pal")
,
for more on adding your own pal prompts, sharing them with others, and
using prompts from others.
Examples
if (FALSE) {
# print out the current prompt directory
directory_get()
# list out prompts currently in the directory
directory_list()
# create a prompt in the prompt directory
prompt_new("boop", "replace")
# view updated list of prompts
directory_list()
# register the prompt with the package
# (this will also happen automatically on reload)
directory_load()
# these are equivalent:
directory_set("some/folder")
options(.pal_dir = "some/folder")
}