Skip to content
Advertisement

How to open a folder in Ranger with explorer.exe (Cygwin)

In windows when you use ranger(by using cygwin), how can you open folders with explorer.exe? I mean when you press r on a folder, it will ask you to open-width a command, but if you write explorer.exe "$1" it doesn’t open it, how can we do it?

Advertisement

Answer

Because the paths in windows and Linux are different, you can’t open folders selected in ranger with explorer.exe.

/cygwin/c/backup isn’t equal to c:backup, and won’t work with explorer.exe.

So we have to change the path, to the one that windows like it.

Open your rifle.py file, if you don’t know where is it and how to create it see this Link

Now at the end of that file, you can add this line:

directory, else = explorer.exe "$(echo "$1" | cat | sed -r 's~/cygdrive/(.)/(.*)~ 1:/2 ~g' | cat | sed 's~/~\~g' | sed -r 's~^ (.*)~1~g')"

It’s a bunch of sed commands that convert the Linux(Cygwin) path model to windows like path. and the open that path with explorer.exe(you can change explorer.exe with any other program you like).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement