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?


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.

  • Thanks for the answer, but I don't want to use another command other than cd. Also it seems that the script would modify the "Edited" date, not the "Last opened" date. – Boykodev Mar 23 '17 at 16:59
  • @Boykodev touch changes the modification and access date! – klanomath Mar 23 '17 at 17:05
  • yeah, you're right. – Boykodev Mar 23 '17 at 17:17
  • touch and cd - interesting... – wogsland Mar 23 '17 at 17:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .