LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Analogy to Windows shortcut that's NOT a symlink? (https://www.linuxquestions.org/questions/linux-newbie-8/analogy-to-windows-shortcut-thats-not-a-symlink-4175448070/)

doncristobal 01-31-2013 07:31 PM

Analogy to Windows shortcut that's NOT a symlink?
 
In Linux (more precisely in Xfce's Thunar), is there a way to create a link that does not create a new representation of already existing data but that simply makes me jump to the target?

An example: "$ ln -s /media/data/xyz ~/Desktop/xyz" creates a symbolic link to /media/data/xyz on my Desktop. Very fine. I can "$ cd ~/Desktop/etc/", or I can navigate to ~/Desktop/etc/, and maybe there is a big folder structure hidden in this xyz folder (~/Desktop/etc/gi/ga/gu/...).
But I'd like cd (or at least Thunar) to jump to /media/data/xyz! Is there any way to achieve this? It's what a Windows shortcut does, and it could be useful in some situations. [edit: as Grail pointed out, Windows only works like this in the gui. The Windows terminal can't handle .lnk files like this. See 3rd post.]

Oh, I'm /sure/ this question has been answered before, but I've spent quite a while searching...

grail 01-31-2013 09:02 PM

I am confused by the following statement:
Quote:

I'd like cd (or at least Thunar) to jump to /media/data/xyz!
Where does cd or Thunar take YOU? Or are you more asking that once there and you do something like cd .. that it then takes you to /media/data?

Also, when making a claim, such as:
Quote:

It's what a Windows shortcut does
You may wish to provide exact details. I say this as I just created a shortcut to a directory on a Win XP machine which is on my desktop.
On traversing to the Desktop folder and issuing a cd command to the same lnk file created I receive:
Code:

c:\>cd "Documents and Settings\grail\Desktop"
c:\Documents and Settings\grail\Desktop>dir
 Volume in drive C has no label.
 Volume Serial Number is F401-FEEB

 Directory of C:\Documents and Settings\grail\Desktop

01/02/2013  10:35    <DIR>          .
01/02/2013  10:35    <DIR>          ..
31/08/2012  12:34              736 Notepad++.lnk
01/02/2013  10:35              352 Shortcut to grail.lnk
28/08/2012  11:35              570 SQL Developer.lnk
              3 File(s)          1,658 bytes
              2 Dir(s)  212,671,336,448 bytes free

c:\Documents and Settings\grail\Desktop>cd "Shortcut to grail.lnk"
The directory name is invalid.

So you may need to explain just how it works on Windows??

doncristobal 02-01-2013 03:25 AM

Oh, I was not aware of the fact that the Windows terminal can't handle .lnk files. I was only thinking of the gui. Thank you, Grail, for this piece of information. So I fully take back the statement that I'd like to see original Windows (TM) behaviour. As usual, I'd like something _better_ than Windows ;-)
I'll give an example of what I'd /like/ to see:

Code:

~/Desktop$ ln -s /media/data/xyz
~/Desktop$ cd xyz
/media/data/xyz$

Instead I do see (the only difference is on the last line):

Code:

~/Desktop$ ln -s /media/data/xyz
~/Desktop$ cd xyz
~/Desktop/xyz$

Thunar closely follows this logic, i.e. it pretends there actually /are/ folders like ~/Desktop/xyz/gi/ga/gu

Why do I ask this question? I've created a similar symlink on my girlfriend's computer for her documents folder. Now I'd prefer her not to get confused with data existing in two separate places. However, sometimes she is bound to go to the original place as Thunar and encfs produce an error under the symlink in some circumstances. I hope my question is clearer now.

grail 02-01-2013 05:59 AM

Ok ... so i played around a little (as this is not a feature I understand wanting) and found the following:
Code:

-P      If  set,  the shell does not follow symbolic links when executing commands such as cd that change the current working directory.  It uses the physical directory structure instead.  By default, bash follows the
                      logical chain of directories when performing commands which change the current directory.

So, if you create an alias for cd to now always execute cd -P you will follow the link to it's actual location. As for having your file manager follow the same process,
you will probably need to either find out how it currently performs the task and change it or go to their forums to see if it is possible without recoding / recompiling the code.

Hope that helps a little.

btw. I would point out it may just be easier to explain to your girlfriend that the data is in only one place but there are multiple ways to get there.
My mother was in her 60s when I switched her to Linux and she managed :)

doncristobal 02-01-2013 11:23 AM

Cool! That's an answer for the shell, thank you. Now I'll just have to find out if Xfce's Thunar can do the same thing. About educating women... you know how good it feels to offer smooth solutions that do not require too much learning ;-)

I found out something interesting: You can do
Quote:

$ set -P
if you want cd and similar commands to change their behaviour in the described way in the current session.

If you want the change to be permanent, add
Quote:

set -P
to your ~/.bashrc

Source: http://linux.about.com/library/cmd/blcmdl1_cd.htm


All times are GMT -5. The time now is 09:38 AM.