Skip to content
Draft
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ If you wish to specify a custom path to your language server, you can do so via
}
```

## Running PowerShell code

This extension provides task templates for running PowerShell code:

- **PowerShell: Run Selection** — runs the currently selected text
- **PowerShell: Run File** — runs the current file

These tasks are available via the `task: spawn` action.

To bind `F8` for running selected text (like PowerShell ISE and VS Code), add the following to your `keymap.json`:

```json
{
"context": "Editor && extension == powershell",
"bindings": {
"f8": ["task::Spawn", { "task_name": "PowerShell: Run Selection" }]
}
}
```

## Configuring your language server settings

Additionally, you can configure settings for your language server as well as initialization options
to pass to the language server on start.

Expand Down
12 changes: 12 additions & 0 deletions languages/powershell/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"label": "PowerShell: Run Selection",
"command": "pwsh",
"args": ["-NoLogo", "-NoProfile", "-Command", "$ZED_SELECTED_TEXT"]
},
{
"label": "PowerShell: Run File",
"command": "pwsh",
"args": ["-NoLogo", "-NoProfile", "-File", "$ZED_FILE"]
}
]