I found the command I want to use:
cd $(ls -d */|head -n 1) and it works as expected when I do it in the terminal. However when I map it in ranger (either with
map g1 cd... or
map g1 shell cd...) I don't get it to work.
Could it be that ranger doesn't support nested commands?
The answer works, for clarity sake what I wanted to do was to have one keybinding in ranger that cd's me into the first of the currently visible folders, one keybinding that cd's me into the second etc. Also for example to cd into the third folder I discovered that I need to use
cd $(ls -d */ |head -n 3 | tail -1) which in line with the answer would translate to
map g3 eval from ranger.ext.spawn import spawn; fm.cd(spawn("ls -d */|head -n 3| tail -1").strip())