cd on quit
rovr
can be configured to change the current directory to the directory you were when you quit it.
how it works
Section titled “how it works”when cd_on_quit
is enabled, rovr
will write the path of its current directory to a file named rovr_quit_cd_path
in your config directory right before it exits.
a small script or function in your shell’s configuration file can then read this file, cd
into the saved directory, and then delete the file.
enabling cd_on_quit
Section titled “enabling cd_on_quit”to enable this feature, you need to set the cd_on_quit
option to true
in your config.toml
file.
[settings]cd_on_quit = true
shell configuration
Section titled “shell configuration”After enabling the feature, you need to add a function to your shell’s configuration file. This function will wrap the rovr
command.
rovr () { "rovr" "$@" cd_path_file="$XDG_CONFIG_HOME/rovr/rovr_quit_cd_path" if [ -f "$cd_path_file" ]; then cd "$(cat "$cd_path_file")" rm -f "$cd_path_file" fi}
function rovr command rovr $argv set cd_path_file "$XDG_CONFIG_HOME/rovr/rovr_quit_cd_path" if test -f "$cd_path_file" cd (cat "$cd_path_file") rm -f "$cd_path_file" endend
function rovr { param ( [string[]]$Params ) & rovr.exe $Params $cd_path_file = "$env:LOCALAPPDATA\rovr\rovr_quit_cd_path" if (Test-Path $cd_path_file) { Set-Location -Path (Get-Content $cd_path_file) Remove-Item $cd_path_file }}
Powershell may prevent you from running such functions, so you may have to run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
for it to work. For more information on Set-ExecutionPolicy
, refer to its docs