Is it possible to create script hooks which are run when entering a given folder?

I want to creat a script in `my_dir/` , say
% hook_me.m
display('foo bar baz');
which should be run whenever I change the MATLAB current folder to `my_dir/`.
Is that possible?

1 comentario

Why? What are you actually planning on having this script do? [I'm guessing the "disp" statement is just a placeholder.]
Depending on the answers to those questions there may be an alternate way to achieve you goal (putting your code in a Project, for example.)

Iniciar sesión para comentar.

 Respuesta aceptada

You would have to define your own cd.m that used builtin('cd') first and then detected whether you were in one of the target directories and if so ran the hook code.
There is no supported way of adding hooks to changing directories.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Dic. de 2024

Respondida:

el 13 de Dic. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by