… These are not to be confused with the shell’s cd command. This is about ranger’s :cd command. Looking at the documentation for :cd with ?c, the -r flag forces a “real” path. So IIUC it expands symlinks. The first mapping would change ranger’s directory to the symlink-resolved path of the current directory, the second mapping would move into the highlighted directory after it is symlink-resolved.
So if I type gL when a file which is a symlink is highlighted, I’m moved to the folder containing the original file and the original file is now highlighted.
I still don’t understand what gl does. Baby steps.
Well, playing around in ranger, it seems that gl and gL does the same thing except gL select the original file that was selected in the simlinked directory while gl resolves the simlink but does not highlight the file you selected.
ex: while selecting the directory /lib/bash
pressing gl redirect you to /usr/lib/ but does not select the directory bash necessarily.
(the selection depends on your browsing history)
I use it quite a bit on my headless enos server to copy files from a USB thumb drive.
Cd to an existing directory where you want to copy the file to
Then mount the USB Thumb drive to /mnt
$ cd ~/username/Temp
$ lsblk -f
$ sudo mount /dev/sda /mnt
$ cp /mnt/somedirectory/somefile .
$ sudo umount /mnt
The . will represent the current working directory for the target directory
Anyway, you can use . to represent the current working directory in various CLI commands.
It it just a shorthand kind of thing that is mostly only useful in a terminal situation.
Also can use … in cd commands
$ cd ..
will move you back one directory towards /
$ cd ../..
will move you back two directories towards /
$ cd ../Temp
will move back one directory then switch to directory Temp from there.
One can also use . as part of the full pathname when executing a file that is not in the $PATH.
As long as you are in the directory containing the app
So this will execute somescript in the current working directory.
For those who learn best by doing, like myself, here is a follow along tutorial on a few bash commands;
:cd [-r] <path>
The cd command changes the directory.
If the path is a file, selects that file.
The command 'cd -' is equivalent to typing ``.
Using the option "-r" will get you to the real path.
So imagine that you go through a symlink to some directory ~/somelink/workdir which you can see at the top of the screen. You are in that directory and it is referenced by a relative path.
When you use cd -r . it will dereference that to absolute path /somewhere/workdir.
The symlink ~/somelink was pointing to /somewhere.
As @Pudge pointed out . just means this directory I am currently in and %f is in ranger just a placeholder meaning the file my cursor is pointing at.
What bugged me was that just following the simlink would also redirect me to the real path, so I did not understood the need for the command at all. But I have a better understanding of the concept now.