Search code examples
bashcygwinstartupstartupscript

Cygwin startup script


How can I run a script inside cygwin after it launches?

I want to automatically add some mounts and run other scripts inside cygwin whenever it starts. I see that in linux it is as simply as adding a shell file inside etc/init.d However, i tried adding this dir and chmod +x add a shell, chmod that shell file, but does not work.

Also if there is a way to run scripts when closing like umount, rmdir and others.


Solution

  • What you are looking for is

    ~/.bash_profile
    

    AKA

    C:\cygwin\home\CPJ\.bash_profile
    

    With a stock install this file is read on Cygwin startup. If you would like to add more files you can edit the .bash_profile file, for example

    source foo.sh
    source bar.sh
    source baz.sh
    

    Bash man page