Skip to content

cd on quit

rovr can change the current directory to wherever you were when you quit using the --cwd-file CLI option.

The --cwd-file option writes the current working directory to a specified file when rovr exits:

Terminal window
# Create a temporary file and use it with rovr
cwd_file=$(mktemp -t rovr_cwd.XXXXXX)
rovr --cwd-file "$cwd_file"
cd "$(cat "$cwd_file")"
rm -f "$cwd_file"

You can create wrapper functions in your shell config for convenience:

.bashrc / .zshrc
rovr () {
local cwd_file=$(mktemp -t rovr_cwd.XXXXXX)
command rovr --cwd-file "$cwd_file" "$@"
if [ -f "$cwd_file" ]; then
cd "$(cat "$cwd_file")"
rm -f "$cwd_file"
fi
}

rovr also supports other Yazi-style CLI options for direct integration with scripts and tools:

Write selected files to a specified file when rovr exits:

Terminal window
# Using a temporary file
chooser_file=$(mktemp -t rovr_selected.XXXXXX)
rovr --chooser-file "$chooser_file"
while IFS= read -r file; do
echo "Selected: $file"
done < "$chooser_file"
rm -f "$chooser_file"

You can use both options together:

Terminal window
# Using temporary files for both options
cwd_file=$(mktemp -t rovr_cwd.XXXXXX)
chooser_file=$(mktemp -t rovr_selected.XXXXXX)
rovr --cwd-file "$cwd_file" --chooser-file "$chooser_file"
# Process results
cd "$(cat "$cwd_file")"
while IFS= read -r file; do
echo "Selected: $file"
done < "$chooser_file"
# Clean up
rm -f "$cwd_file" "$chooser_file"

as much as it might be tempting, this will not work. i use helix btw and just like superfile, it just cannot launch the app. i’m not sure why, but it might be a conflict between terminal buffer areas. so something like yazi’s

[keys.normal]
C-y = [
':sh rm -f /tmp/unique-file',
':insert-output rovr %{buffer_name} --chooser-file=/tmp/unique-file',
':insert-output echo "\x1b[?1049h\x1b[?2004h" > /dev/tty',
':open %sh{cat /tmp/unique-file}',
':redraw',
]

will not work