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

This plugin requires a Rust version of at least 1.77.2

Platform Level Notes
windows
linux
macos
android

Only allows to open URLs via open

ios

Only allows to open URLs via open

Setup

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';
// when using `"withGlobalTauri": true`, you may use
// const { Command } = window.__TAURI__.shell;
let result = await Command.create('exec-sh', [
'-c',
"echo 'Hello World!'",
]).execute();
console.log(result);

Permissions

By default all potentially dangerous plugin commands and scopes are blocked and cannot be accessed. You must modify the permissions in your capabilities configuration to enable these.

See the Capabilities Overview for more information and the step by step guide to use plugin permissions.

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
}
]
}
]
}

Default Permission

This permission set configures which shell functionality is exposed by default.

Granted Permissions

It allows to use the open functionality without any specific scope pre-configured. It will allow opening http(s)://, tel: and mailto: links.

  • allow-open

Permission Table

Identifier Description

shell:allow-execute

Enables the execute command without any pre-configured scope.

shell:deny-execute

Denies the execute command without any pre-configured scope.

shell:allow-kill

Enables the kill command without any pre-configured scope.

shell:deny-kill

Denies the kill command without any pre-configured scope.

shell:allow-open

Enables the open command without any pre-configured scope.

shell:deny-open

Denies the open command without any pre-configured scope.

shell:allow-spawn

Enables the spawn command without any pre-configured scope.

shell:deny-spawn

Denies the spawn command without any pre-configured scope.

shell:allow-stdin-write

Enables the stdin_write command without any pre-configured scope.

shell:deny-stdin-write

Denies the stdin_write command without any pre-configured scope.


© 2024 Tauri Contributors. CC-BY / MIT