Ranger cd into a folder (and invoke shell)?

I found the answer to this in the man pages:

S Open a shell in the current directory

Yes, probably should have read through that before asking here.


You could also use :cd /path/to/folder if you are already in Ranger.

Update: The question has been edited since this answer was given, making it invalid.


Another approach is to have the underlying shell "follow" ranger(1) around the filesystem so that after navigating to a new directory and ranger(1) is quit (or suspended; usually ctrl+z) the underlying shell will already be in the same directory ranger(1) was quit in.

To do this, have the shell "source" ranger(1) either by prefixing the command with the word . (i.e., the dot or period character) or the word source on some shells.

. ranger

Now your shell will "follow" ranger(1) around the filesystem.

This works because the ranger command (which is python script) has an embedded bash(1) script that is read when sourcing the file. Note that, it only works on bash(1) compatible shells.

From a comment block in the script:

This embedded bash script can be executed by sourcing this file. It will cd to ranger's last location after you exit it. The first argument specifies the command to run ranger, the default is simply "ranger". (Not this file itself!) The other arguments are passed to ranger.

If this becomes your preferred mode to use ranger(1) in, add it as an alias in your shells initialization script.