How make the terminal run a script when it load?
Hey @Miguel_exe,
- You can create a
start.sh
script, put all the shell commands you would like to run in thestart.sh
file and in thepackage.json
, add a start script like this:
"scripts": {
"start": "bash start.sh"
},
- Or you can use the
child_process
module to run shell commands using Node.js.
const { exec } = require("child_process");
exec("ls", (error, stdout, stderr) => {
if (error) {
console.log(error.message);
return;
}
if (stderr) {
console.log(stderr);
return;
}
console.log(`Output: ${stdout}`);
});
Hope this helps!
im mean when load it load a shell script
like ohmyzsh auto updater, it load when zsh loads up
You can put stuff in a .bash_profile script. It runs whenever you open a new terminal.
It will run globally (in all projects)
If yes i want it just for this project
if you want to run a script then i reccommend making it in one project and running CURL in the other to execute it
Ok, but i have the file
I need make bash run it without in other projects
Just in my project
so you just want it to run in one project, it always does because it can`t and should not really connect to another project
globally means it works all around the container instead of one folder
Try it. Yes, it will only run for the project you add the script to.
But i wanna run this script when terminal load
Not when project load
putting it in ,bash_profile will run the command when you open the terminal, not the project
But it will run the script globally? (in all projects)
no, it will run globally in all folders in that one project
So it means it will run in all projects or what?
no… the .bash_profile will only be read and executed by the project it is held in, it won`t be ran anywhere outside that container.
But .bash_profile file dosent exist
you make the file in the editor first
But glitch editor hide files what start with .
Except .env
yes, but you can write to it first. . files are only hidden to non-project members