How to...run a cmd on opening a folder?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
MBaas
Posts: 580
Joined: 15 Feb 2016 21:08

How to...run a cmd on opening a folder?

Post by MBaas »

I am trying to improve my workflow and am unsure how to best do this with XY, so would appreciate some insight from the Pro's:
  • I have a folder \Git that contains lot of repos that I work on.
  • been struggling some time to find the best way of storing these links (Hamburger-menu, Catalog etc.), but I ended up by creating a dedicated tab with a locked location and FVS that only show the list of folder-names and this seems to be the approach that works best (to keep them easily acessible).
  • next challenge is: I select a repo and want to do something with it. That something can be several activities, so what I probably would like most is:
    • navigate that list
    • select a folder and "enter" on it - but when I am in the special context of this c:\git in the locked pane, I would like "Open Folder" to instead run a script (that launches my "repository-activity-selector").
So that means I want to customize "Open Folder" (by mouseclick or kbd) for one folder only (coz I do not want to have to create a separate menu-item for it - just using the "natural" way of acting on "OpenFolder" seems to be the most natural way. Is that even possible?

Or perhaps that sounds to crazy? Maybe there's a better way to do this?
______________________________________________
Happy user ;-)

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: How to...run a cmd on opening a folder?

Post by bdeshi »

No, overriding the "folder open" action is not possible.
You can assign a custom file association for the Git folder's subfolder, and you'll have to run this custom action from the Open With menu.
I've assigned the INSERT key to "File > Open With..." so it's still one click.

Or, you can assign a custom column for that folder with FVS. The custom column should have the trigger "Click", and then you'd write a small script for the column to open your "repository-activity-selector". The custom column will display a nice triangular Play button (if the default skin is used.)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

MBaas
Posts: 580
Joined: 15 Feb 2016 21:08

Re: How to...run a cmd on opening a folder?

Post by MBaas »

The custom column sounds like a nice idea - but there are so many items that I switched to List View to see them all - and that does not show the column.
So I tried to set up a custom action in OpenWith - but it's not showing.
Here's what I entered:

Code: Select all

c:\git\ >:run "c:\batch\repo.cmd" "<curitem>"
I can't see what I did wrong there...
______________________________________________
Happy user ;-)

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: How to...run a cmd on opening a folder?

Post by bdeshi »

::run ...
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

MBaas
Posts: 580
Joined: 15 Feb 2016 21:08

Re: How to...run a cmd on opening a folder?

Post by MBaas »

Thanks - but still no joy :(

Code: Select all

c:\git\>::run "c:\batch\repo.cmd" "<curitem>"
______________________________________________
Happy user ;-)

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: How to...run a cmd on opening a folder?

Post by bdeshi »

Sorry. You need to throw away that last slash.

Code: Select all

c:\git>::run "c:\batch\repo.cmd" "<curitem>"
Since folder PFAs don't work as default command, I define them as secondary/POM-only records by prepending a pipe.

Code: Select all

|c:\git>::run "c:\batch\repo.cmd" "<curitem>"
POM-only entries only show up in the Open With menu, and never activate by default with enter or double click. This future-proofs against surprises in case folder PFAs gain defaultiness in the future.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

MBaas
Posts: 580
Joined: 15 Feb 2016 21:08

Re: How to...run a cmd on opening a folder?

Post by MBaas »

Ah - I may have mis-expressed my case or misunderstood - but finally

Code: Select all

|c:\git\*>::run "c:\batch\repo.cmd" "<curitem>"
does what I wanted: it acts on the subfolders within c:\git.

Actually...folder PFAs gaining defaultiness in the future would be a very welcome extension :)
______________________________________________
Happy user ;-)

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: How to...run a cmd on opening a folder?

Post by jupe »

Well there is a tweak: PFADefaultOpenFolders=1

You may have to setup some conditional PFA entries to make it work how you want though, also keep in mind it is only triggered from the list, not tree or breadcrumb etc.

for instructions on how to tweak: https://www.xyplorer.com/faq-topic.php?id=tweak

MBaas
Posts: 580
Joined: 15 Feb 2016 21:08

Re: How to...run a cmd on opening a folder?

Post by MBaas »

Thanks, that useful!
______________________________________________
Happy user ;-)

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: How to...run a cmd on opening a folder?

Post by bdeshi »

Ah, completely forgot about that :blackstorm: . Thanks jupe.
Added in 15.70.0119:

Code: Select all

v15.70.0119 - 2015-09-14 20:16
    + Portable File Associations: Added tweak PFADefaultOpenFolders to allow 
      customizing the default action on dbl-click/enter on folders.
        PFADefaultOpenFolders=1
      Handle with care. You cannot use folders in the list for browsing anymore 
      when you set this tweak.
      They are either opened by a PFA to folders (\ = match any folder) like 
      this:
        \>::msg "It's a folder: <pfaitem>";
      Or they are opened by the OS-default (e.g. Windows Explorer, or another 
      instance of XYplorer).
Also MBaas, sorry, I indeed forgot to note the "subfolder" bit.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

MBaas
Posts: 580
Joined: 15 Feb 2016 21:08

Re: How to...run a cmd on opening a folder?

Post by MBaas »

Oh well, I certanly did not want to affect OpenFolder everywhere...so I un–tweaked, will have to live with the additional step then.
______________________________________________
Happy user ;-)

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: How to...run a cmd on opening a folder?

Post by jupe »

It wouldn't affect it everywhere, if there is no matching PFA entry then it works just as per normal, the info SammaySarkar posted is outdated if you are basing your un-tweaking on it (ie. without testing), its functionality has changed since, and as I mentioned in my previous post you just create an additional PFA entry with a higher priority if you want it to do something else instead in other locations, or add conditionals to your current entry, anyway it is up to you if you use it or not, personally I never bother with automation like this either, 1 or 2 clicks isn't a burden to me.

PS: You'd need to remove the | pipe prefix from your example entry above for it to work, and maybe add it to other entries if you did actually test it and you had other things run when trying to browse.

MBaas
Posts: 580
Joined: 15 Feb 2016 21:08

Re: How to...run a cmd on opening a folder?

Post by MBaas »

Priorities? Conditionals?
RTFM–time again, I guess 8)
______________________________________________
Happy user ;-)

Post Reply