0.2.8 • Published 5 years ago
@khai96x/choose-text-editor v0.2.8
Choose Text Editor
Get path to a text editor executable base on some environment variables
Configuration
Location
This package uses cosmiconfig to load configuration. It will search files with matching name from working directory to stopDir (default to home directory).
Names:
choose-text-editor(yaml format)choose-text-editor.jsonchoose-text-editor.yamlchoose-text-editor.config.jschoose-text-editor.jspackage.json#choose-text-editorpackage.yaml#choose-text-editor
Schema
A config file have a structure satisfies schemas/editor-set.schema.json or EditorSet interface
Example Configuration
{
"$schema": "https://raw.githubusercontent.com/KSXGitHub/personal-packages/%40khai96x/choose-text-editor/0.2.1/packages/choose-text-editor/schemas/editor-set.schema.json#",
"graphical": [
{ "program": "code", "flags": ["wait"] },
{ "program": "atom", "suffixes": ["--wait"] }
],
"terminal": [
{ "program": "vim" }
],
"chooser": "@khai96x/choose-text-editor@^0.2.1"
}Environment Variables
- When
FORCE_EDITORis set,choose-text-editorwill skip reading config and choose forced editor. - When
FORCE_EDITORis not set,ISINTTYmust always be set to eithertrueorfalse(case-sensitive):ISINTTY=trueto consider only terminal editors.ISINTTY=falseto consider graphical editors before terminal editors.
FORCE_EDITOR_PREFIXESwhen set, must be a valid yaml array of string. This prefix will be added to output command line.
Basic Commands
Find an editor and display its command
ISINTTY=false
choose-text-editorFind an editor to open a file
ISINTTY=false
choose-text-editor -x exec -- my-file.txtPrint help message
choose-text-editor --help