How can I open ~/Desktop if I click on "Open in terminal" from the Desktop?
Solution 1:
Script-less solution
- Open Nautiuls in your home folder.
- In your home folder, right click on
Desktop
, clickMake link
. You will be presented withLink to Desktop
file. - 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
- Create, if it doesn't exist yet, the directory
~/.local/share/nautilus/scripts
- Copy the script below into an empty file, save it as
terminal_here2
(no extension), and make it executable - Log out and back in.
Now right-click on any file on your desktop, choose Scripts --> open_terminal2:
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")