task: Add ZED_RELATIVE_DIR task variable (#31657)
This is my first contribution to zed, let me know if I missed anything. There is no corresponding issue/discussion. `$ZED_RELATIVE_DIR` can be used in cases where a task's command's filesystem namespace (e.g. inside a container) is different than the host, where absolute paths cannot work. I modified `relative_path` to `relative_file` after the addition of `relative_dir`. For top-level files, where `relative_file.parent() == Some("")`, I use `"."` for `$ZED_RELATIVE_DIR`, which is a valid relative path in both *nix and windows. Thank you for building zed, and open-sourcing it. I hope to contribute more as I use it as my primary editor. Release Notes: - Added ZED_RELATIVE_DIR (path to current file's directory relative to worktree root) task variable.
This commit is contained in:
parent
b4af61edfe
commit
ae076fa415
4 changed files with 20 additions and 2 deletions
|
@ -80,6 +80,7 @@ These variables allow you to pull information from the current editor and use it
|
|||
- `ZED_FILENAME`: filename of the currently opened file (e.g. `main.rs`)
|
||||
- `ZED_DIRNAME`: absolute path of the currently opened file with file name stripped (e.g. `/Users/my-user/path/to/project/src`)
|
||||
- `ZED_RELATIVE_FILE`: path of the currently opened file, relative to `ZED_WORKTREE_ROOT` (e.g. `src/main.rs`)
|
||||
- `ZED_RELATIVE_DIR`: path of the currently opened file's directory, relative to `ZED_WORKTREE_ROOT` (e.g. `src`)
|
||||
- `ZED_STEM`: stem (filename without extension) of the currently opened file (e.g. `main`)
|
||||
- `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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue