Add ranger function to cd on exit with Q key
This commit is contained in:
parent
312e645e9e
commit
eec4abcb12
1 changed files with 14 additions and 0 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue