Add best practices section

pull/522/head
Arijit Basu 2 years ago committed by Arijit Basu
parent 91e3990df1
commit 88fe71779b

@ -19,8 +19,7 @@ A minimal plugin should confirm to the following structure:
└── init.lua
```
You can also use
[this template][2].
You can also use [this template][2].
### README.md
@ -51,6 +50,18 @@ to append `.xplr` to the name to make them distinguishable. Similar to the
Finally, after publishing, don't hesitate to
[let us know][4].
## Best practices
- Try not to execute a lot of commands at startup, it may make xplr slow to
start.
- When executing commands, prefer `Call0` over `Call`, `BashExec0` over
`BashExec` and so on. File names may contain newline characters
(e.g. `foo$'\n'bar`).
- File names may also contain quotes. Use the syntax
`printf 'Call0: "%s"' "${FOO_ESC}"` where `FOO_ESC=${FOO//\"/\\\"}`.
- Check for empty variables using the syntax `${FOO:?}` or use a default value
`${FOO:-defaultvalue}`.
## Examples
Visit [Awesome Plugins][5] for xplr plugin examples.

@ -1803,9 +1803,9 @@ xplr.config.modes.builtin.delete = {
fi
else
if rm -v -- "${LINE:?}"; then
printf 'LogSuccess: "%s"\0' "$line deleted" >> "${XPLR_PIPE_MSG_IN:?}"
printf 'LogSuccess: "%s"\0' "$LINE_ESC deleted" >> "${XPLR_PIPE_MSG_IN:?}"
else
printf 'LogError: "%s"\0' "Failed to delete $line" >> "${XPLR_PIPE_MSG_IN:?}"
printf 'LogError: "%s"\0' "Failed to delete $LINE_ESC" >> "${XPLR_PIPE_MSG_IN:?}"
fi
fi
done < "${XPLR_PIPE_RESULT_OUT:?}")

Loading…
Cancel
Save