Skip to content

Latest commit

 

History

History
137 lines (93 loc) · 5.04 KB

FAQ.md

File metadata and controls

137 lines (93 loc) · 5.04 KB

Scripthaus FAQ

Does any information ever leave my system?

No, ScriptHaus runs 100% locally. At no time does ScriptHaus transfer any of your scripts, markdown, or history to a remote server.

What environments does ScriptHaus support?

You can use ScriptHaus on Mac OS X (recommended) and Linux systems. Windows is not currently supported, please reach out if you would like to help port and test it.

What languages are supported in code blocks?

ScriptHaus supports "sh", "bash", "zsh", "tcsh", "ksh", "fish", "python", "python2", "python3", "js", and "node". Note: "js" and "node" are synonyms, and care should be taken when using "sh" as it is just an alias for another shell (so it is not portable).

For the shells, the command is passed using "-c" (so it should with any compatible shell). Python is executed using "-c" and node commands are executed using "--eval". For shells, $0 is set to the command-name (python and node do not allow it to be overridden).

Can I make commands in my README.md executable?

Sure (same for BUILD.md or any other markdown file you already have)! Any code fence can be made executable by adding:

# @scripthaus command [name] - [short-description]

Now you can run it from the command-line using:

scripthaus run ./README.md::[name]

How do I save the last command I typed?

You can save the last command you typed by using scripthaus "add". Add will add a new code-fenced scripthaus block to the end of the markdown file specified.

scripthaus add ./commands.md::new-command-name -t bash -m "my cool command" -c "!!"

For more help/options you can run scripthaus help add. Note that if the markdown file you wish to add to does not exist, scripthaus will refuse to add the command, just "touch" file first and the add will work. Since playbooks are just markdown files, you can edit them however you normally edit markdown.

How can I see what commands are available in a markdown file?

scripthaus show [markdown-file]

This will show you the scripthaus commands in the given markdown file (with their short descriptions). If you want to get help on a specific command run:

scripthaus show [markdown-file]::[command]

This will show the full code for the command as well as the help text from the surrounding markdown.

How does ScriptHaus generate the help text for a command?

Help text is generated by traversing upwards from the code fence that holds the ScriptHaus command. It will not pass a level 1-4 header, thematic break, or another code fence. Level 4 headers will be included as part of the help, level 1-3 headers will not.

How can I create global commands?

Put global commands in a file named scripthaus.md in your ScriptHaus home directory. Any command placed there can be accessed easily using ^[command-name]. Other files in your ScriptHaus home directory can accessed as ^[md-file]::[command-name].

How can I create commands specific to a project?

Put a scripthaus.md file in your project root directory. When you are in that directory, or any sub-directory, and command in that file can be accessed easily using .[command-name]. Other sibling files to the scripthaus.md file (which must be present) can be accessed using .[md-file]::[command-name].

By default commands are run in your current command-line directory (which may be a project sub-directory). If you want commands to run with the project root set as the working directory, be sure to add the cd directive # @scripthaus cd :playbook to your commands.

Where is my ScriptHaus home directory?

It is located at $HOME/scripthaus. It can be overridden by setting the $SCRIPTHAUS_HOME environment variable.

What are ScriptHaus directives?

Directives are special comments in your code that ScriptHaus parses to affect command execution. They always start as a language specific comment with @scripthaus as the first identifier, and the directive name as the 2nd. The rest of the line is the directive body.

The 'command' directive marks a code block as a scripthaus command (this directive is always necessary). It sets the command name. It can be followed by an optional " - " (white-space around the dash is necessary) to add a short description.

# @scripthaus command [command-name] - [short description]

The 'cd' directive will change the directory that the command runs in. It must be an absolute path (or one of the allowed special names). Normal shell path expansion is not run, except "~" will be expanded to your home directory.

# @scripthaus cd [directory]
# @scripthaus cd ~/Downloads

# ':playbook' means to set the current directory to the directory where this playbook lives
# @scripthaus cd :playbook

The 'nolog' directive turns off history logging for this command (unless it is explicitly overriden on the command-line using '--log'.

# @scripthaus nolog

How can I disable history completely?

Touch the file .nohistory in your ScriptHaus home directory.

Do you have command completion?

No, not yet. I'm working on a bash completion script.