Reputation: 2901
Mac 11.4
My current function opens a new terminal, then in the old terminal runs a C program.
foo() {
open -a Terminal -n; cd ~/desktop/c; ./target.exe
}
What I want it to do is to open a new terminal and run the C program inside the new terminal.
Is this possible to do with a Zsh function?
Upvotes: 0
Views: 2362
Reputation: 26377
Save following script in run-command.zsh :
#!/usr/bin/env zsh
run-command(){
local tmp=$(mktemp)
echo "rm $tmp; cd '$PWD'; $*" > $tmp
chmod 755 $tmp ; open -a Terminal $tmp
}
run-command "$@"
and run it with
chmod +x ./run-command.zsh
./run-command.zsh top
Once you tested "top" successfully, you can run :
./run-command.zsh "cd ~/desktop/c; ./target.exe"
Upvotes: 1