Reputation: 1922
I have a shell script that I want to run globally. It's current directory is
~/directory/script.sh
I can run the script only from the directory in which the script is located, however, I'd like to run it from every directory, not just the one that it's in.
I'm using Git bash in Windows 10. I've tried putting this line at the top of the file:
#!usr/local/bin
but that didn't work (probably because I'm using Windows), the bash said it doesn't recognize it.
I also tried using alias
but it's not really a solution.
Is there a different way to run a shell script globally?
Upvotes: 7
Views: 7785
Reputation: 71
git bash loads its global scripts from a directory /usr/bin
which it creates in its windows installation folder, if you place your script there, you should be able to call it from any directory you're in while using git bash
Upvotes: 5
Reputation: 2777
Find your root directory of Git Bash installation and go to /usr/bin
.
For my case, full path is :
C:\Program Files\Git\usr\bin
Copy your script there (you will need Administrator rights). I named my script as my-script.sh
.
#!/bin/bash
echo "Hello World"
Open Git Bash as an Administrator and give your script executable right :
chmod +x /usr/bin/my-script.sh
Upvotes: 7