Page 1 of 1

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

Posted: 21 Jun 2019 17:14
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?

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

Posted: 22 Jun 2019 09:11
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.)

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

Posted: 22 Jun 2019 10:34
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...

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

Posted: 22 Jun 2019 10:37
by bdeshi
::run ...

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

Posted: 22 Jun 2019 10:58
by MBaas
Thanks - but still no joy :(

Code: Select all

c:\git\>::run "c:\batch\repo.cmd" "<curitem>"

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

Posted: 22 Jun 2019 11:33
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.

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

Posted: 22 Jun 2019 14:00
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 :)

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

Posted: 22 Jun 2019 14:06
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

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

Posted: 22 Jun 2019 15:16
by MBaas
Thanks, that useful!

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

Posted: 22 Jun 2019 15:34
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.

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

Posted: 22 Jun 2019 16:06
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.

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

Posted: 22 Jun 2019 16:26
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.

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

Posted: 22 Jun 2019 16:54
by MBaas
Priorities? Conditionals?
RTFM–time again, I guess 8)