Skip to content
Tauri

Shell

Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application.

Supported Platforms

  • Windows
  • Linux
  • macOS

Setup

This plugin requires a Rust version of at least 1.75

Install the shell plugin to get started.

Use your project’s package manager to add the dependency:

npm run tauri add shell

Usage

The shell plugin is available in both JavaScript and Rust.

import { Command } from '@tauri-apps/plugin-shell';
let result = await Command.create('exec-sh', [
'-c',
"echo 'Hello World!'",
]).execute();
console.log(result);

Permissions

By default all plugin commands are blocked and cannot be accessed. You must define a list of permissions in your capabilities configuration.

See Permissions Overview for more information.

src-tauri/capabilities/main.json
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "main-capability",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
{
"identifier": "shell:allow-execute",
"allow": [
{
"name": "exec-sh",
"cmd": "sh",
"args": [
"-c",
{
"validator": "\\S+"
}
],
"sidecar": false
}
]
}
]
}
PermissionDescription
shell:allow-executeEnables the execute command without any pre-configured scope.
shell:deny-executeDenies the execute command without any pre-configured scope.
shell:allow-killEnables the kill command without any pre-configured scope.
shell:deny-killDenies the kill command without any pre-configured scope.
shell:allow-openEnables the open command without any pre-configured scope.
shell:deny-openDenies the open command without any pre-configured scope.
shell:allow-stdin-writeEnables the stdin_write command without any pre-configured scope.
shell:deny-stdin-writeDenies the stdin_write command without any pre-configured scope.

© 2024 Tauri Contributors. CC-BY / MIT