def searchHist(hist, text, tty):
    """Search back for text in stack and select directory if found"""
    for dir in hist[1:]:
        if text in dir:
            print(dir)
            return 0
    tty.write('cdhist: string "{}" not found\n'.format(text))
    return 1
