Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

1 total

How to keep the list of completed print jobs empty

export PATH=/usr/bin:/bin:/usr/sbin:/sbin
export IFS=$' \t\n'

echo 'Hello, world!' | enscript -q -B --word-wrap -f Helvetica30 -p - | lpr

/usr/bin/lpstat -W completed
/usr/bin/lpstat -W not-completed

# clear the whole print queue
#/usr/bin/cancel -a -    

# remove individual print jobs from the queue
defaultprinter=$(/usr/sbin/system_profiler SPPrintersDataType | egrep -B 5 'Default: Yes' | head -n 1 | sed -e 's/^[[:space:]]*//' -e 's/:$//')
alias opendefaultprinter='/usr/bin/open -a "$defaultprinter"'

opendefaultprinter


man 5 cupsd.conf

# make a backup of cupsd.conf
/usr/bin/sudo /bin/cp -p /private/etc/cups/cupsd.conf /private/etc/cups/cupsd.conf.orig  

# get line numbers of matching lines
sed -E -n -e '/cups/=' /private/etc/cups/cupsd.conf
sed -E -n -e '/^#PreserveJobHistory[[:space:]]+Yes/=' /private/etc/cups/cupsd.conf
sed -E -n -e '/^[[:space:]]*PreserveJobHistory[[:space:]]+Yes/=' /private/etc/cups/cupsd.conf
sed -E -n -e '/^[[:space:]]*PreserveJobHistory[[:space:]]+No/=' /private/etc/cups/cupsd.conf

open -e /private/etc/cups/cupsd.conf
nano /private/etc/cups/cupsd.conf


# disable PreserveJobHistory in cupsd.conf
/usr/bin/sudo /bin/ed -s /private/etc/cups/cupsd.conf <<< $',s|^#*PreserveJobHistory Yes|PreserveJobHistory No|\nw'

/usr/bin/sudo /usr/bin/killall -HUP cupsd    # reload cupsd.conf

# enable PreserveJobHistory in cupsd.conf
/usr/bin/sudo /bin/ed -s /private/etc/cups/cupsd.conf <<< $',s|^[[:space:]]*PreserveJobHistory No|PreserveJobHistory Yes|\nw'

/usr/bin/sudo /usr/bin/killall -HUP cupsd


# Mac OS X 10.5: Removing information about completed print jobs,
# http://support.apple.com/kb/HT1857
# http://developer.apple.com/documentation/Darwin/Reference/ManPages/man8/cupsctl.8.html

man 8 cupsctl
cupsctl PreserveJobHistory=No
cupsctl PreserveJobHistory=Yes
1 total