zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.53k stars 3.13k forks source link

Allow for tasks to pull current open directory #16418

Open AarnavSin opened 3 months ago

AarnavSin commented 3 months ago

Check for existing issues

Describe the feature

Currently, Zed Tasks only have a way to reference one set directory via cwd. However, in some use cases, having the ability to pull the current open directory in your Zed window for that particular task could be helpful. For example, I was writing a task to allow me to easily create and open a file inside the terminal using the following code:

#!/bin/bash

read -p "Enter filename: " filename
touch "$filename"
zed "$filename"

However, by default this file gets created in the project root directory and not the subfolder which is currently open. To my knowledge there's no way to tell it to create the file in the open subfolder. Even adding lines in the shell script to use pwd to at least pull the current terminal directory doesn't work correctly.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

notpeter commented 3 months ago

We support Task Variables in task definitions.

Would ${ZED_DIRNAME} in cwd meet your needs?

ZED_DIRNAME: absolute path of the currently opened file with file name stripped (e.g. /Users/my-user/path/to/project/src)