# Zsh wrapper for the `trail` terminal file manager.
#
# Source this file in your ~/.zshrc to enable the "cd-on-exit" behaviour:
# when you quit Trail normally (`q`), your current shell session changes to
# the directory Trail was browsing.
#
# Installation:
# echo 'source /path/to/trail.zsh' >> ~/.zshrc
# source ~/.zshrc
#
# Usage:
# trail [<start-path>] # launches Trail; on normal exit, `cd`s to the
# # last-visited directory.
#
# How it works:
# The wrapper creates a temporary file and passes its path to the Trail
# binary via --cwd-file. On a normal exit Trail writes its current
# directory to that file; the wrapper reads it, removes it, then `cd`s
# into the directory. On cancellation (Ctrl-c / Esc quit) Trail writes
# nothing, so the shell stays where it was.