autoloading functions

  1. create a functions directory
        $ cd
        $ mkdir myfunctions
        $ cd myfunctions
    
  2. create two files in the myfunctions directory
        $ touch hello1 hello2
    
  3. here are the contents of hello1
     
    function hello1
    {
    print "hello1 fxn"
    }
    
    
  4. here are the contents of hello2
     
    function hello2
    {
    print "hello2 fxn"
    }
    
  5. add the following lines to your $ENV file
    FPATH=$HOME/myfunctions
    export FPATH
    autoload $(ls $FPATH)
    
  6. create a script inside the derek directory
        $ cd
        $ cd derek
    
  7. here are the contents of the script called hello.sh
    #!/usr/bin/sh
    
    print "inside the the $0 script"
    
    hello1
    hello2
       
    
  8. now run the hello.sh script