From eec4abcb12bd73810f879513a069a24b654363cb Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Tue, 14 Nov 2023 08:48:18 +0100 Subject: [PATCH] Add ranger function to cd on exit with Q key --- private_dot_config/private_fish/config.fish.tmpl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/private_dot_config/private_fish/config.fish.tmpl b/private_dot_config/private_fish/config.fish.tmpl index 39d84b8..625836a 100644 --- a/private_dot_config/private_fish/config.fish.tmpl +++ b/private_dot_config/private_fish/config.fish.tmpl @@ -96,6 +96,20 @@ if test -e "$HOME/.config/fish/custom.fish" source "$HOME/.config/fish/custom.fish" end +# ranger: Q to cd on exit +function ranger + set tempfile (mktemp -t tmp.XXXXXX) + set command_argument "map Q chain shell echo %d > $tempfile; quitall" + command ranger --cmd="$command_argument" $argv + if test -s $tempfile + set ranger_pwd (cat $tempfile) + if test -n $ranger_pwd -a -d $ranger_pwd + builtin cd -- $ranger_pwd + end + end + command rm -f -- $tempfile +end + # Commands to run in interactive sessions can go here if status is-interactive abbr -a rm "rm --interactive --verbose"