How can I open ~/Desktop if I click on "Open in terminal" from the Desktop?

Solution 1:

Script-less solution

  1. Open Nautiuls in your home folder.
  2. In your home folder, right click on Desktop, click Make link. You will be presented with Link to Desktop file.
  3. Place link on your Desktop. Now whenever you right click on it, and select Open in Terminal it will open terminal with current working directory set as desktop.

Solution 2:

A quick & easy one coincidentally, since I only needed to change a script I already had a bit :).

The script assumes you have at least one item on your desktop though.

How to set up

  1. Create, if it doesn't exist yet, the directory ~/.local/share/nautilus/scripts
  2. Copy the script below into an empty file, save it as terminal_here2 (no extension), and make it executable
  3. Log out and back in.

Now right-click on any file on your desktop, choose Scripts --> open_terminal2:

enter image description here

and a terminal window will open in the desktop's directory ("Bureaublad" in my case)

The script:

#!/usr/bin/env python3
import subprocess
import os

def replace(path):
    for c in [("%23", "#"), ("%5D", "]"), ("%5E", "^"),
              ("file://", ""), ("%20", " ")]:
        path = path.replace(c[0], c[1])
    return path

# get the current path
current = replace(os.getenv("NAUTILUS_SCRIPT_CURRENT_URI")) 
# raise the found terminal window
os.chdir(os.path.realpath(current))
subprocess.Popen("gnome-terminal")