Change directory last opened date every time you `cd` in Terminal

findersmart-foldersterminal

I use a Recent Smart folder, that depends on last opened date of the folder. It works fine when you browsing the Finder, but it doesn't register change when I use cd command in a Terminal.

Is there a way to change last opened date of the folder every time I cd to it in a terminal?

Best Answer

Open .bash_profile - or create it if it doesn't exist.

Add the line:

tcd () { touch "$1" && cd "$1"; }

and save the file.

Source your modified .bash_profile with source ~/.bash_profile or close all Terminal windows currently open.

Use tcd folder_name to cd to it and modify the access date.


You can refine this by adding a condition that the argument has to be a folder.