Is there a way to access the "Recent Items" list from the terminal?
Solution 1:
You can read the recent items plist file.
defaults read $HOME/Library/Preferences/com.apple.recentitems
There's a lot of "noise" in the output. You can filter the "noise" with grep
and list the last entry with tail
which should be the last file opened (but not always the case).
defaults read $HOME/Library/Preferences/com.apple.recentitems | grep "Name" | tail -n 1