3

I need to create a shortcut to a folder in Ubuntu 18.04 like I did it windows. I don't like symlinks for a navigation patterns I have used in windows. Symlink is not the best solution for me just because it works differently. Symlink brings a folder content to another folder, while shortcut helps me to navigate to the source folder.

Let's say I've got a folder with many projects. The one project is a major one which is 80% time spending. I'd like to create a shortcut to it so I can quickly navigate to that project. It might happen on rare occasion I need to navigate to another project then in windows I used to open the main project using that shortcut, THEN I GO ONE LEVEL UP AND SELECT ANOTHER PROJECT. This is not possible with symlinks. Because if I go up after I opened symlink I will be in a wrong place.

With shortcuts I don't need to have that many shortcuts as with symlinks. If I only have symlinks then I need to create at least 2 symlinks where in windows I would have just 1 shortcut.

Keyboard shortcut is not the same. The reson is that I normally create a folder called Links in which I have approximately 10 folder shortcuts. Remembering 10 keyboard shortcuts doesn't look like a great idea.

Creating a .desktop file also seems would not work as I believe it would work for 1 folder.

  • can you specify the path of directory? for example if you want /home/user/foo1/foo2/ – PRATAP Apr 03 '19 at 21:12
  • i think you just need to create a custom keyboard shortcut to quickly reach your directory. this allows level up when you hit backspace. create a custom keyboard shortcut with command nautilus /home/user/foo1/foo2/ – PRATAP Apr 03 '19 at 21:14
  • 3
  • 1
    I just do bookmarks in Nautilus for navigation like you seem to want. I also use symlinks to folders in my data partition, then bookmark a specific folder under my projects or even several levels down. – oldfred Apr 03 '19 at 21:43
  • 1
    I'm not sure you have a proper understanding of symlinks. What you're describing with your Projects is exactly what a symlink would be useful for. You would make a symlink pointing to that folder and place it in your /home/user/Desktop folder. Now you have a direct link to that Projects folder on the Desktop whenever you need to access it. – Paul Benson Apr 03 '19 at 22:24
  • @PaulBenson Symlinks do create a "direct" link, i.e. are transparent to calls to open(), but they obscure the real path of the target's parent directory, e.g pwd -P will give different answers depending on following the symlink or the original path. That's one of the main things the question is asking about. – Nathaniel M. Beaver Sep 14 '20 at 16:32

2 Answers2

1

This way of working is not strongly supported in Ubuntu. Still, you can create a launcher to open a folder by creating a .desktop file.

[Desktop Entry]
Name=Publications folder
Comment=Go to publications
Exec=xdg-open /home/user/Documents/Project
Terminal=false
Icon=
Type=Application

Replace the folder path and name after "xdg-open" with the actual path and name of your folder. You can supply an icon after "Icon="

Make the .desktop file executable (right-click the file, select "Properties", on the "Permissions" tab, check "Allow executing file as program")

You can now

  • Place the file on your desktop
  • Place the file in a hidden folder .local/share/applications in your home folder. Then, this item will show up in your applications. You can therefore quickly launch it as any other program.
  • You can pin the icon to the dash for even quicker access.

Another possibility for quick access to that folder is to pin it as a bookmark in "Files". Highlight the folder in "Files" and drag it on the left bar. Drop it where it says "New bookmark". Shorter, go into the folder you want to bookmark, and press Ctrl+d.

vanadium
  • 88,010
-1

A Link-type desktop file is a good fit for your use-case, since these navigate to the absolute path give by the URL, unlike symbolic links which, as you pointed out, navigate relative to their parent directory, not the parent directory of the target.

For example, if you want to link to /home/my-username/Documents/my-projects/project-1/, use a desktop file like this:

[Desktop Entry]
Name=project-1
Type=Link
URL=file:///home/my-username/Documents/my-projects/project-1/
Icon=folder

A good name for this would be project-1.desktop, but anything ending in .desktop is fine. Double-clicking on this desktop file will open the folder

/home/my-username/Documents/my-projects/project-1/

and from there you can navigate to the parent directory

/home/my-username/Documents/my-projects/

as desired.

Note that the URL must be a file:// URL, which requires an absolute file path and proper percent encoding of characters such as spaces and parentheses. Some file managers have this linking built-in and can assist you in generating these files if you encounter difficulty doing it by hand.

Related:

Nathaniel M. Beaver
  • 1,518
  • 12
  • 33
  • @ThomasWard No, this is emphatically not a duplicate because the other answer is a "Type=Application" (type 1) desktop file and this answer is a "Type=Link" (type 2) desktop file. They are handled differently and have different use-cases. Notably, in most file managers link-type desktop files do not create a new window when followed, which is analogous to a .lnk file. – Nathaniel M. Beaver Sep 10 '20 at 04:16