Custom actions in thunar

I would like to be able to insert the absolute path of a file selected in Thunar in the terminal.

I don't know exactly how to do this. I found instructions on the Internet and did the following:

I set a custom action in Thunar:

It also works that when I now select a file in Thunar and right-click on it, ‘Copy path to clipboard’ appears and I can select that.

If I then right-click again in the terminal and go to paste, a warning message appears:

‘Pasting this text into the terminal may be dangerous as it looks like some commands may be executed.’

Is it dangerous to do this? Is there another easier solution to get this function in Linux? In Windows you can copy the path of any file with a right click.

Edit: It also works simply by copying the file (right-click copy or ctr+c) and then pasting it in the terminal (right-click paste or ctl+shift+v) or by draging the file into the terminal.

That often happens when there is White Space included with the paste. Often, a space or "enter" - it is dropped down a line. You can usually see and remove it but...

You do not need any of that nor a Custom Command.

Just left click the addresbar in Thunar and it transforms into a path in print that you can just copy immediately with ctl+c or with right click (it appears already fully highlighted.). You can type in it too, to direct to a new path.

Then the name of the file is always missing.

If you want a file path included, you only need to Right click that file in that directory and then ctl+shift+v in the terminal (or right click in terminal and select paste) and it will paste the full path and file name.

3 Likes

It's feedback for me to say this, but Copy as Path would be a good addition for the stated goal of being easy to adopt for Windows users. I know and agree some things work differently and users need to embrace a new platform, but I cannot begin to tell you how valuable Copy as Path and Invert Selection were to me in Windows 10 and 11.

In Nautilus I can accomplish the former by right clicking a file and choosing copy, then "Paste as Filenames" in a terminal, but if my destination isn't a terminal (say, I need the file path in a spreadsheet for some reason), I seem to be up a creek.

1 Like

In Core: There is a Gnome Extension that offers this.

In Lite, if you want to copy to, for example text editor - hold ctl and drag the file onto the editor to paste the path with file name.

1 Like

...I will shake my fist at how much requires extensions in GNOME while acknowledging that a solution is a solution. Thanks.

2 Likes

During lockdown when using the terminal to get to a document in a sub directory for say when using pdftk (pdf repair tool) I had to re-learn that unlike Windows which uses forward slashes in a directory tree, GNU/Linux / Unix uses backward slash ( \ ) before the directory name when creating a path.

@Aravisian Do you mean this one?

I found some nice information how to add other custom actions in thunar:

Notice: gksu is no longer usable in Zorin. Replace "gksu" with "pkexec" or if GUI programs don't open with this command replace it with "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY".

Some programs used here in the commands are not installed in Zorin, so you have to install them first or replace them with other Zorin programs.

1 Like

I'd like to add a command like this but for nano or xed. How can I do this?

With
pkexec xed %f
and
sudo nano %f
it didn't work. No text editing program opens after password request.

Is the vertical line a capital I, a small L or a vertical line? Do I need it?

Edit: Using mousepad everything works:
pkexec mousepad %F

But how can I use the other programs?

It is a Line. You find it on a german Keyboard-Layout on the Key with the ''bigger than'', ''smaller than'' Symbols: >< (man kann den Strich mit alt gr aktivieren)

But to come to the Topic with the Path: You could simply type in the Path in the Terminal. Isn't this an Option? I mean in Thunar, you see where you are. so, You could open the Terminal and write it in.

1 Like

Now I added few custom actions to thunar:
copy path
copy to
move to
edit as root
make backup copy

But why don´t they appear in the right click menu when I open thunar as root?

Should the Picture show that it doesn't work? Because the Links are there.

They work, but I had to install mousepad separately and would like to know what the command for the action "Edit as root" should be in order to edit a file with Xed (or Nano).

Edit: I found this command and will try it:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY dbus-launch put-your-favourite-text-editor-here %f

Now it works with xed :grinning_face:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY dbus-launch xed %f

I got nano to work with this command:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY dbus-launch xfce4-terminal -x editor %f

Can please anyone tell me if these commands are safe to use?

Yes, these are generally safe as a sole user.

But if you use those on a shared work environment or public computer, they can open up security exploits (this can be true of many elevated commands.)

That could be it. I do not use Gnome D.E., so my familiarity with extensions is minimal.

1 Like

Why doesn't thunar opend as root have the same right-click menu as the normal thunar?

I just did a quick test... I did not see anything missing. But how it is used, which file, not knowing what I was looking for...
What is missing?

I do not have access to this computer at the moment. But when I opened it as root yesterday, none of my five user-defined commands were displayed in the right-click menu.

On the same file that did have those options on your user account or a different file, different path?