0

What is actual path? Consider folder A in the file system and a symlinked B to it. Consider currently in ranger (or terminal) inside a sub-directory within B such as /home/B/sub1/sub2 which is in fact /another_but_actual_path/A/sub1/sub2. What I want is to have a tool/command/script which convert the relative path to the actual path. I mean while pwd shows /home/B/sub1/sub2, I want to access the path /another_but_actual_path/A/sub1/sub2.

p.s. I tried readlink but it couldn't give me the actual path.

p.s. I don't know if so called actual path has a name or not.

  • The realpath command? – Stephen Harris Nov 22 '18 at 2:38
  • @StephenHarris, yep! – SdidS Nov 22 '18 at 2:38
  • @StephenHarris, if you can please provide the answer with some more useful information to get approved or feel free to remove the whole question. – SdidS Nov 22 '18 at 2:40
1

The standard Linux "coreutils" package contains a command realpath.

This will follow any and all symbolics links for the named path, and return the "real" path associated with it.

So:

$ mkdir -p /tmp/foo/bar
$ ln -s /tmp/foo $HOME/foo
$ realpath $HOME/foo
/tmp/foo
$ realpath $HOME/foo/bar
/tmp/foo/bar
$ realpath $HOME/foo/bar/baz
/tmp/foo/bar/baz

We can see that the link $HOME/foo is being replaced by the real path of /tmp/foo.

The last entry need not exist, but all intermediate points must.

$ realpath $HOME/foo/bar/baz/qux
realpath: '/home/sweh/foo/bar/baz/qux': No such file or directory

That's because there is no baz directory.

  • based on this I tried map gR cd "$(realpath $(pwd))" in ranger config (rc.conf) but it dident' work. It might be due to something with ranger and how it represent the path but any clue? – SdidS Nov 22 '18 at 2:54
1

In Ranger you can use the gl and gL commands. Type g, then:

key          command
 L           cd -r %f
 l           cd -r .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.