Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 102 additions & 4 deletions src/content/docs/features/shell.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,109 @@ title: Shell
description: Access the system shell to manage files and URLs using their default application and to spawn child processes.
---

import Stub from '@components/Stub.astro';
import PluginLinks from '@components/PluginLinks.astro';
import { Tabs, TabItem } from '@astrojs/starlight/components';
import CommandTabs from '@components/CommandTabs.astro';

<PluginLinks plugin="shell" />

<Stub>
Based on https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/shell
</Stub>
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.

<Tabs>
<TabItem label="Automatic">

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

{' '}

<CommandTabs
npm="npm run tauri add shell"
yarn="yarn run tauri add shell"
pnpm="pnpm tauri add shell"
cargo="cargo tauri add shell"
/>

</TabItem>
<TabItem label="Manual">

1. Install the Core plugin by adding the following to your `Cargo.toml` file:

```toml title="src-tauri/Cargo.toml"
[dependencies]
tauri-plugin-shell = "2.0.0-beta"
# alternatively with Git:
tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
```

2. Modify `lib.rs` to initialize the plugin:

```rust title="src-tauri/src/lib.rs" {3}
fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
```

3. Install the JavaScript Guest bindings using your preferred JavaScript package manager:

<CommandTabs
npm="npm install @tauri-apps/plugin-shell"
yarn="yarn add @tauri-apps/plugin-shell"
pnpm="pnpm add @tauri-apps/plugin-shell"
/>
</TabItem>
</Tabs>

## Usage

The plugin's APIs are available through the JavaScript guest bindings:

```javascript
import { Command } from "@tauri-apps/plugin-shell";

Command.create("git", ["commit", "-m", "the commit message"]);
```

## Permissions

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

See [Access Control List](/references/v2/acl) for more information.

```json title="src-tauri/capabilities/main.json" ins={4-7}
{
"permissions": [
...,
"shell:allow-execute",
"shell:allow-kill",
"shell:allow-open",
"shell:allow-stdin-write",
]
}
```

| Permission | 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-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.|
2 changes: 1 addition & 1 deletion src/content/docs/features/window-state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn main() {

## Usage

After adding the all windows will remember their state when the app is being closed and will restore to their previous state on the next launch.
After adding the plugin all windows will remember their state when the app is being closed and will restore to their previous state on the next launch.

You can also access the window-state plugin in both JavaScript and Rust.

Expand Down