cd on quit
rovr can change the current directory to wherever you were when you quit using the --cwd-file CLI option.
Using --cwd-file
Section titled “Using --cwd-file”The --cwd-file option writes the current working directory to a specified file when rovr exits:
# Create a temporary file and use it with rovrcwd_file=$(mktemp -t rovr_cwd.XXXXXX)rovr --cwd-file "$cwd_file"cd "$(cat "$cwd_file")"rm -f "$cwd_file"shell configuration
Section titled “shell configuration”You can create wrapper functions in your shell config for convenience:
rovr () { local cwd_file=$(mktemp -t rovr_cwd.XXXXXX) command rovr --cwd-file "$cwd_file" "$@" if [ -f "$cwd_file" ]; then local new_loc=$(cat "$cwd_file") if [ -n "$new_loc" ] && [ "$new_loc" != "$PWD" ]; then cd "$new_loc" fi rm -f "$cwd_file" fi}function rovr set cwd_file (mktemp -t rovr_cwd.XXXXXX) command rovr --cwd-file "$cwd_file" $argv if test -f "$cwd_file" set new_loc (cat "$cwd_file") if test -n "$new_loc" -a "$new_loc" != "$PWD" cd "$new_loc" end rm -f "$cwd_file" endenddef --env --wrapped rovr [...args: string] { let cwd_file = (mktemp -t rovr_cwd.XXXXXX) ^rovr --cwd-file $cwd_file ...$args if ($cwd_file | path exists) { let new_path = ($cwd_file | open | str trim) if ($new_path != "" and $new_path != $env.PWD) { cd $new_path } rm -fp $cwd_file }}function rovr { $cwd_file = New-TemporaryFile & rovr.exe --cwd-file $cwd_file $args if (Test-Path $cwd_file) { $new_loc = Get-Content $cwd_file if (-not [String]::IsNullOrEmpty($new_loc) -and $new_loc -ne (Get-Location).Path) { Set-Location $new_loc -ErrorAction SilentlyContinue } Remove-Item $cwd_file }}Powershell may prevent you from running such functions, so you may have to run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachinefor it to work. For more information on Set-ExecutionPolicy, refer to its
docs
Additional CLI options
Section titled “Additional CLI options”rovr also supports other Yazi-style CLI options for direct integration with scripts and tools:
--chooser-file
Section titled “--chooser-file”Write selected files to a specified file when rovr exits:
# Using a temporary filechooser_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"Combined usage
Section titled “Combined usage”You can use both options together:
# Using temporary files for both optionscwd_file=$(mktemp -t rovr_cwd.XXXXXX)chooser_file=$(mktemp -t rovr_selected.XXXXXX)rovr --cwd-file "$cwd_file" --chooser-file "$chooser_file"
# Process resultscd "$(cat "$cwd_file")"while IFS= read -r file; do echo "Selected: $file"done < "$chooser_file"
# Clean uprm -f "$cwd_file" "$chooser_file"integrations
Section titled “integrations”this is an example integration with helix
[keys.normal]C-y = [ ':open %sh{rovr %{buffer_name} --chooser-file=__stdout__ --force-tty}', ':redraw',]will not work
Both --chooser-file and --cwd-file lets you write to stdout and stderr.
To do so, wrap them with double underscores, and include --force-tty to ignore piping status
(rovr --chooser-file __stdout__ --force-tty) -split "`n" | ForEach-Object { Get-Item $_ }