- `ZED_SYMBOL`: currently selected symbol; should match the last symbol shown in a symbol breadcrumb (e.g. `mod tests > fn test_task_contexts`)
- `ZED_SELECTED_TEXT`: currently selected text
- `ZED_WORKTREE_ROOT`: absolute path to the root of the current worktree. (e.g. `/Users/my-user/path/to/project`)
- `ZED_CUSTOM_RUST_PACKAGE`: (Rust-specific) name of the parent package of $ZED_FILE source file.
To use a variable in a task, prefix it with a dollar sign (`$`):
```json
{
"label": "echo current file's path",
"command": "echo $ZED_FILE"
}
```
You can also use verbose syntax that allows specifying a default if a given variable is not available: `${ZED_FILE:default_value}`
These environmental variables can also be used in tasks' `cwd`, `args`, and `label` fields.
### Variable Quoting
When working with paths containing spaces or other special characters, please ensure variables are properly escaped.
For example, instead of this (which will fail if the path has a space):
```json
{
"label": "stat current file",
"command": "stat $ZED_FILE"
}
```
Provide the following:
```json
{
"label": "stat current file",
"command": "stat",
"args": ["$ZED_FILE"]
}
```
Or explicitly include escaped quotes like so:
```json
{
"label": "stat current file",
"command": "stat \"$ZED_FILE\""
}
```
## Oneshot tasks
The same task modal opened via `task: spawn` supports arbitrary bash-like command execution: type a command inside the modal text field, and use `opt-enter` to spawn it.
The task modal persists these ad-hoc commands for the duration of the session, `task: rerun` will also rerun such tasks if they were the last ones spawned.
You can also adjust the currently selected task in a modal (`tab` is the default key binding). Doing so will put its command into a prompt that can then be edited & spawned as a oneshot task.
### Ephemeral tasks
You can use the `cmd` modifier when spawning a task via a modal; tasks spawned this way will not have their usage count increased (thus, they will not be respawned with `task: rerun` and they won't have a high rank in the task modal).