A plugin utilizing FZF to change directory needs help

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
skywind3000
Junior Member
Junior Member
Posts: 4
Joined: 2020-10-30, 14:22 UTC

A plugin utilizing FZF to change directory needs help

Post by *skywind3000 »

I am developing a plugin for fast directory changing, it will use the well known fuzzy finder - fzf to match the path history.

Once the path is selected, it will notify TC to make source panel jump in the new path:

Image: https://skywind3000.github.io/images/p/misc/wx20201030223252.png

It will be an efficient way to access most recently accessed pathes.

But it appears that there is no way for me to retrive path history in TC.

Is there a way that TC can provide a hook, and call it everytime path changing happens in the left/right panel ?
The hook can be either a TC user defined command or external program. If so, I can record the latest path in a local database.

I have noticed that there are "[lefthistory]" and "[righthistory]" in the wincmd.ini, but both of them do not update in realtime.
So the plugin has no chance to read the new path in time.

So, my question is, is it possible to call a command (or an external program) every time the source/target path changes ?
or update "[lefthistory]" and "[lefthistory]" section everytime when they changed ?

Or any way to get the path history in realtime ?
User avatar
nsp
Power Member
Power Member
Posts: 1804
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: A plugin utilizing FZF to change directory needs help

Post by *nsp »

Old xcd was already working with fuzzy search a bit like agrep search on top of complete wc tree file

You have a TC command to save config history ( cm_ConfigSaveDirHistory 582 ) and one to save all ( cm_ConfigSaveSettings 580). So you do not need any hook to get notified at each foler change (Specially because TC do not remember all path but only the ones where you stay a little).
So my advise is more to call TC to save history when you want to use your companion plugin/soft.

If you send message with copy data to total commander current instance you can change folder as you want or just call TC with parameter if single instance is set.

I personally use a modified version of SpeedDial command line using EVerything see on VoidTools forum. And still use XCD on a large bookmark file.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: A plugin utilizing FZF to change directory needs help

Post by *Horst.Epp »

I don't see any big advantage of such a plugin.
Using Everything and JumpToFolder or Everything Toolbar
its so easy and fast to jump to any file or folder in TC
so the normal history is enough.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
skywind3000
Junior Member
Junior Member
Posts: 4
Joined: 2020-10-30, 14:22 UTC

Re: A plugin utilizing FZF to change directory needs help

Post by *skywind3000 »

@Horst.Epp, the idea is inspired by z.sh: https://github.com/rupa/z
Frecency:
Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted
rank that depends on how often and how recently something occurred. As
far as I know, Mozilla came up with the term.

To z, a directory that has low ranking but has been accessed recently
will quickly have higher rank than a directory accessed frequently a
long time ago.

Frecency is determined at runtime.
Everything always take a long time to warm up the database each time it starts.
And when I use it to search directories, it always suggests many useless directories
which I will never enter.

So I decide to track the directory changing and sort them by frecency, which means
directories with higher frecency always come first.

Both autojump and z.sh are well known command line productivity tool, their idea
could make path changing faster in TC.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: A plugin utilizing FZF to change directory needs help

Post by *Horst.Epp »

skywind3000 wrote: 2020-10-30, 17:26 UTC @Horst.Epp, the idea is inspired by z.sh: https://github.com/rupa/z
...
Everything always take a long time to warm up the database each time it starts.
And when I use it to search directories, it always suggests many useless directories
which I will never enter.

So I decide to track the directory changing and sort them by frecency, which means
directories with higher frecency always come first.

Both autojump and z.sh are well known command line productivity tool, their idea
could make path changing faster in TC.
Everything running in the background together with its service as suggested
always delivers results in seconds for me.
You can also enter simple words to narrow the results.
In JumpToFolder you can even use the Run count as sort order to get most used entries first.
Also this way I go to any file or folder fast and not only to the ones I visited in the past.
I guess you are not very familar with Everything and the related AHK tools. :)
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
jinsight
Senior Member
Senior Member
Posts: 299
Joined: 2003-02-25, 19:47 UTC
Location: Wooster, Ohio, USA

Re: A plugin utilizing FZF to change directory needs help

Post by *jinsight »

Support ++

Post by horst.epp » Thu Oct 29, 2020 10:47 am in voidtools forum
One more suggestion for your context menu: of JumpToFolder
Add a context menu item like "Open Special".
This should allow to select once any tool which in the future will be started with the entry as parameter.
This way I could directly jump to any entry (Folder or File) in Total Commander without additional steps.
Currently I use the Copy to clipboard and later jump to the clipboard content in Total Commander.
This would also work with many other file managers.
Best implementation would be to also allow additional parameters for the tool definition.
This would allow calling explorer like
Explorer.exe /select,"%1"
License #1945
Windows 10 Pro x64
Version 22H2 (OS Build 19045.3930)
TC 11.00 x64 and x86, Everything 1.5.0.1366a x64, QAP 11.6.3.1 x64
skywind3000
Junior Member
Junior Member
Posts: 4
Joined: 2020-10-30, 14:22 UTC

Re: A plugin utilizing FZF to change directory needs help

Post by *skywind3000 »

nsp wrote: 2020-10-30, 15:53 UTC Old xcd was already working with fuzzy search a bit like agrep search on top of complete wc tree file

You have a TC command to save config history ( cm_ConfigSaveDirHistory 582 ) and one to save all ( cm_ConfigSaveSettings 580). So you do not need any hook to get notified at each foler change (Specially because TC do not remember all path but only the ones where you stay a little).
So my advise is more to call TC to save history when you want to use your companion plugin/soft.

If you send message with copy data to total commander current instance you can change folder as you want or just call TC with parameter if single instance is set.

I personally use a modified version of SpeedDial command line using EVerything see on VoidTools forum. And still use XCD on a large bookmark file.
@nsp, thanks for your help, my addon released:

https://github.com/skywind3000/tcz_cd

It will follow the most recently accessed rules and can be more efficient than "Everything".
Post Reply