Part of https://github.com/zed-industries/zed/issues/5141 * adds "run selection" and "run file" tasks for bash and Python. * replaces newlines with `\n` symbols in the human-readable task labels * properly escapes task command arguments when spawning the task in terminal Caveats: * bash tasks will always use user's default shell to spawn the selections, but they should rather respect the shebang line even if it's not selected * Python tasks will always use `python3` to spawn its tasks now, as there's no proper mechanism in Zed to deal with different Python executables Release Notes: - Added tasks for bash and Python to execute selections and open files in terminal
19 lines
666 B
Rust
19 lines
666 B
Rust
use language::ContextProviderWithTasks;
|
|
use task::{TaskTemplate, TaskTemplates, VariableName};
|
|
|
|
pub(super) fn bash_task_context() -> ContextProviderWithTasks {
|
|
ContextProviderWithTasks::new(TaskTemplates(vec![
|
|
TaskTemplate {
|
|
label: "execute selection".to_owned(),
|
|
command: VariableName::SelectedText.template_value(),
|
|
ignore_previously_resolved: true,
|
|
..TaskTemplate::default()
|
|
},
|
|
TaskTemplate {
|
|
label: format!("run '{}'", VariableName::File.template_value()),
|
|
command: VariableName::File.template_value(),
|
|
..TaskTemplate::default()
|
|
},
|
|
]))
|
|
}
|