Provide more robust .bashrc function to gen index.