Search code examples
linuxcygwin

Cygwin bash files


About a year ago, I created a couple text files called "compile" and "pull." When I go into a cygwin prompt and type those names and hit enter (basically use them as a command), the cygwin terminal runs what is in those text files. For instance here is the contents of one:

git checkout master
git checkout -- .

I don't even remember how I did this. I'm pretty sure this is not a bash script.

I do remember that I had to not just create the file in notepad but also perform some linux command line operation on it, in order to use it. Once I did that I could basically use the file as a command.


Solution

  • In *nix, you have to make a file executable in order to be able to run it:

    chmod u+x file
    

    You also need to add the path to the file to the PATH variable

    PATH=$PATH:/path/to/the/file
    

    or, add . to always scan the current directory for commands (it's considered unsecure, though):

    PATH=$PATH:.