Paco

Personal Content Organiser

Home / Mac

Navigation

Menu

Search

Lion - Recent Items List

Lion lists recent items with each application in the Dock (accessible via right-click) and in the Application View of Mission Control. To remove those and disable future additions, run the following commands in the Terminal.

Note that to figure out the application's bundle identifier, you can open Activity Monitor, click the application in the list of processes and then click the ???Sample Process??? button. Then makes sure the ???Display:??? popup is set to ???Sample Text???."


Sampling process 3407 for 3 seconds with 1 millisecond of run time between samples

Sampling completed, processing symbols... Analysis of sampling QuickTime Player (pid 3407) every 1 millisecond Process: QuickTime Player [3407] Path: /Applications/QuickTime Player.app/Contents/MacOS/QuickTime Player Load Address: 0x10e72e000 Identifier: com.apple.QuickTimePlayerX Version: 10.1 (501) Build Info: QuickTimePlayerX-501000000000000~3 Code Type: X86-64 (Native) Parent Process: launchd [180] [...]



Now, to disable recent item listing for Quicktime, you would issue the following commands in Terminal:

defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit 0

defaults delete com.apple.QuickTimePlayerX.LSSharedFileList RecentDocuments

defaults write com.apple.QuickTimePlayerX.LSSharedFileList RecentDocuments -dict-add MaxAmount 0


Restart QuickTime and your recent items should be cleared and no longer cached.


Solution 2




1. in the shell, create a text file and open TextEdit:
$ touch fhistory.txt
$ open fhstory.txt


2. paste the script from below into this file and then save and close (make sure you start with the '#! /bin/sh line' and end with the 'fi' on the last line)

3. back in the shell rename the file and make it executable:
$ mv fhistory.txt fhistory.sh
$ chmod +x fhistory.sh


4. use the script with these variations:

Display the history:
$ fhistory.sh TextEdit


Delete and disable the history:
$ fhistory.sh -d TextEdit


Enable the history:
$ fhistory.sh -e TextEdit


Script:
#! /bin/sh # # fhistory.sh # # Written in 2011 by Marcel Egloff # # A basic tool to display, enable or disable the (global) recent file history for an individual Application # # Use it at your own risk and do with it what you want as long as you don't blame me! # PROGRAM=`basename $0` USAGE=`printf "%%i-$PROGRAM: usage: %s [-ed] Application\n" $PROGRAM` enable=0 disable=0 while getopts ed opt; do case $opt in e) enable=1;; d) disable=1;; ?) echo $USAGE exit 1;; esac done shift `expr $OPTIND - 1` if [ $# -eq 1 ]; then application=$1 else echo $USAGE exit 1 fi extension=`echo $application | awk -F. '{ print $NF }'` if [ "$extension" != "app" ]; then application="$application.app" fi dir=`dirname $application` if [ "$dir" != "." ]; then path=$application else path=`find ~/Applications/* -name "$application"` if [ -z "$path" ]; then path=`find /Applications/* -prune -name "$application"` fi fi if [ -n "$path" ]; then if [ -f "$path/Contents/Info.plist" ]; then if [ -x /usr/libexec/PlistBuddy ]; then identifier=`/usr/libexec/PlistBuddy -c "print CFBundleIdentifier" "$path/Contents/Info.plist"` else printf "%%i-$PROGRAM: PlistBuddy not found in /usr/libexec - aborting\n" exit 1 fi else printf "%%i-$PROGRAM: Info.plist not found in '$path/Contents' - aborting\n" exit 1 fi else printf "%%i-$PROGRAM: Application '$application' not found\n" exit 1 fi if [ -n "$identifier" ]; then echo "Path: $path" echo "Identifier: $identifier" if [ $enable -eq 0 -a $disable -eq 0 ]; then echo max=`defaults read $identifier.LSSharedFileList RecentDocuments 2> /dev/null | grep 'MaxAmount' | sed 's:[^0-9]*::g'` if [ -z "$max" ]; then echo "No history found - system defaults will be applied." else echo "Maximum number of files in history: $max" echo n=1 defaults read $identifier.LSSharedFileList RecentDocuments 2> /dev/null | grep 'Name[ ]*=' | awk -F'"' '{ print $2 }' | while read file; do printf "%2d. %s\n" $n "$file" n=$[n+1] done fi elif [ $enable -eq 0 ]; then defaults write $identifier NSRecentDocumentsLimit 0 defaults delete $identifier.LSSharedFileList RecentDocuments defaults write $identifier.LSSharedFileList RecentDocuments -dict-add MaxAmount 0 printf "%%i-$PROGRAM: file history disabled\n" else read line defaults delete $identifier NSRecentDocumentsLimit read line defaults write $identifier.LSSharedFileList RecentDocuments -dict-add MaxAmount 10 # should supply the system wide default here printf "%%i-$PROGRAM: file history enabled\n" fi else printf "%%i-$PROGRAM: Application identifier not found\n" fi




Source: https://discussions.apple.com/thread/3200017?start=0&tstart=0