To have zsh autoload functions, you can place them in a directory and have zsh search the path when the functions are called. For example, consider a function foo defined in ~/functions/foo. In your ~/.zshrc add:
FPATH=~/functions:$FPATH autoload foo
Then, whenever you call foo, zsh will attempt to read ~/functions/foo for the function definition. To reload a function after you have changed its source file, run:
unfunction foo autoload foo
The next invocation of the function will cause a reload of ~/functions/foo.
autoloadfunctionspathreloadzsh
You can edit an environment variable in-place by running vared:
$ vared PATH
It will give you a readline-style buffer to edit the variable's contents and will save them back to the environment after you're done.
environmentpathreadlinevaredzsh
If you need to tell a python framework where your templates, etc. are located, it helps to determine the location of the current module.
BASE_PATH = os.path.abspath(os.path.join(os.path.dirname(__FILE__), '..')) TEMPLATES = os.path.join(BASE_PATH, 'templates')
Assuming you're running this code in /path/to/module.py, BASE_PATH will be set to /path. Other os.path tricks can be used to dynamically set paths in this way.
locationosparsingpathpython
Make sure you always specify a path free of symlinks. This can be pretty tough, though. An alternative approach is to use namei to track down symlinks:
# namei /usr/X11/bin/xterm f: /usr/X11/bin/xterm d / d usr l X11 -> X11R6 d X11R6 d bin - xterm
commandsdirectorynameipathshellsymlinkstree