Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-09-05 07:42:11

undercover_agent
Member
Registered: 2023-09-05
Posts: 8

How do I "cd -P" a symlink in Thunar? [SOLVED]

I have looked everywhere, and there does not seem to be a way to do this by default in Thunar? I just want to "back out" into the "real" parent...
(here is a "problem-solution" for the terminal https://unix.stackexchange.com/question … -by-a-link )

If a workaround is possible as a custom action, that would be swell!  I have written a few CA-scripts, but I don't see a way to force thunar to "change dir" this way? (I am also not really a programmer.)

Any ideas? Maybe I am missing something?

Last edited by undercover_agent (2023-09-05 11:25:45)


^ - ^

Offline

#2 2023-09-05 10:07:52

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,034

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

Hello and welcome.

See this existing functionality enhancement request.

As for a custom action, try this (it will open a new thunar window in the link's directory and allow you to traverse that directory using the back buttons):
- Name = Move Into...
- Command = thunar "$(readlink %f)"
- Icon = YOUR_CHOICE
- Appearance = Directories

Alternatively, it you want to re-use the same thunar window, you could try using xdotool and the following command:

sh -c "xdotool key Ctrl+L type $(readlink %f); xdotool key Enter"

Last edited by ToZ (2023-09-05 10:08:39)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2023-09-05 11:21:26

undercover_agent
Member
Registered: 2023-09-05
Posts: 8

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

I did indeed want to re-use the same window:
Confirmed working!
Thank you! :)

P.s. My previous workaround was: RMB inside link -> Properties -> Copy "Link Target" line -> Paste in location bar
Which was not that fun...


^ - ^

Offline

#4 2023-11-03 04:37:32

mocha
Member
Registered: 2022-12-12
Posts: 16

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

This is a nice solution but doesn't work when there are spaces in the directory path.  How do you escape it?  I tried quotes and so on, nothing works.

Offline

#5 2023-11-03 09:17:14

undercover_agent
Member
Registered: 2023-09-05
Posts: 8

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

Can confirm. Haven't noticed before -I guess I did not have any such links...
I am no bash programmer, but it seems thunar returns spaces as "%" and readlink (or realpath) doesn't like it. I tried reformatting, but i dont know how to do it one line for thunar for this solution...? Might be wrong tho.


^ - ^

Offline

#6 2023-11-03 11:29:10

eriefisher
Member
From: ON, Canada
Registered: 2008-10-25
Posts: 415

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

I'm not sure how to do it correctly but you could search and insert it into the string above.

However, this is Linux, there shouldn't be any spaces used in directory paths. If it's a two or more word name I use "-" to make it one. It saves a lot of frustration later. Like now.


Siduction
Debian Sid
Xfce 4.18

Offline

#7 2023-11-03 12:07:34

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,034

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

Weird, but I had to move it into a script and not run it via "sh -c" to get it to work.

Create a script with the following content:

#!/bin/sh
LINK=$(readlink "$1")
xdotool key Ctrl+l
xdotool type "$LINK"
xdotool key Enter

...and make it executable.

Then change to custom action to point to this script.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#8 2023-11-03 13:06:07

undercover_agent
Member
Registered: 2023-09-05
Posts: 8

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

Can confirm it works. Thanks! 

I created a test link with spaces as I did not have any. (Though, I will not go into what "should" and "should not" be possible on linux.)


^ - ^

Offline

#9 2023-11-04 18:07:22

mocha
Member
Registered: 2022-12-12
Posts: 16

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

Thanks for the fix.  I had to make the last line "xdotool key Return" because the script wasn't working and then when I debugged I was getting the message "(symbol) No such key name 'Enter'. Ignoring it." so I changed it to Return and now it works as expected.

Is there a way to adapt this to open the containing directory for a symlinked file?  I'm going to play around with it and see.

Last edited by mocha (2023-11-04 18:13:18)

Offline

#10 2023-11-04 18:31:00

mocha
Member
Registered: 2022-12-12
Posts: 16

Re: How do I "cd -P" a symlink in Thunar? [SOLVED]

Here's what I came up with for a script that opens the containing folder of a symlinked file.

#!/bin/sh
LINK="$(dirname "$(readlink "$1")")"
xdotool key Ctrl+l
xdotool type "$LINK"
xdotool key Return

I called the custom action "Open Containing Folder..." and set it to appear only for files not directories.  The action points to the script with a %f passed to it.

Offline

Board footer

Powered by FluxBB