Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
fix: prevent asking user for terminal permissions (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelOnFira committed May 28, 2024
1 parent 7c63efd commit a1a75d8
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions cli/src/commands/sidekick/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,28 @@ impl SubCommand {
.into_os_string()
.into_string()
.unwrap();
let command_to_run = format!("cd {}; {}", current_dir, args.join(" "));

let apple_script = format!(
"tell application \"Terminal\"
activate
do script \"{}\"
end tell",
command_to_run

// Create the content for the script
let script_path = format!("{}/script.command", current_dir);
let command_to_run = format!(
"cd \"{}\" && {} && rm \"{}\"",
current_dir,
args.join(" "),
script_path
);

Command::new("osascript")
.arg("-e")
.arg(apple_script)
// Write the script content to the script file
std::fs::write(&script_path, format!("#!/bin/bash\n{}", command_to_run))?;
std::fs::set_permissions(
&script_path,
std::os::unix::fs::PermissionsExt::from_mode(0o755),
)?;

// Use `open` to run the script
std::process::Command::new("open")
.arg(&script_path)
.spawn()
.expect("Terminal failed to start");
.expect("Failed to open script");
}

#[cfg(target_os = "linux")]
Expand Down

0 comments on commit a1a75d8

Please sign in to comment.