parsed.org

Tips by tag: path

Autoloading and Reloading Functions by cygnus on Jan 19, 2005 04:09 PM

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
Environment Variable Editing by cygnus on Jan 19, 2005 10:39 PM

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
Path Calculation by xinu on Mar 30, 2007 01:13 PM

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
Tracking Down Symlinks by xinu on Jun 24, 2005 01:41 PM

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
RSS