I have at the bottom of my .zshrc
[[ -e $HOME/.myapp/myapp.sh ]] && source $HOME/.myapp/myapp.sh
myapp.sh loads some environmental variables from a file called script_properties
{ [[ -e $HOME/.myapp/script_properties ]] && source $HOME/.myapp/script_properties; } || {printf "Please run setup script to set build configuration defaults.\n" && exit; }
and then checks a directory (lt_shell_functions_dir) where there are some bash scripts that I want to load as zsh functions. My hope is to be able to from the command prompt do something like "ltbuild", which is the name of a bash script that I want to run as a function. When I run "autoload ltbuild" from a zsh command prompt, it loads the file as a function (because it is in my fpath) and I can run it. When I try to load this from inside a script that executes on startup, so that I don't have to type "autoload ltbuild" it doesn't work. I appreciate the help!
if [[ -d $lt_shell_functions_dir ]]; then
fpath=($lt_shell_functions_dir $fpath)
for function_file in $lt_shell_functions_dir/*
do
autoload $function_file || printf "Autoloading $function_file failed\n"
done
unset function_file
else
printf "no $lt_shell_functions_dir exists.\n"
fi
Example:
I have a file named echome that has in it:
echo "I'm a file running as a function"
When I start a shell:
[carl@desktop[ 3:06PM]:carl] echome
zsh: command not found: echome
[carl@desktop[ 3:06PM]:carl] autoload echome
[carl@desktop[ 3:07PM]:carl] echome
I'm a file running as a function