Snippet Collection

An evergrowing quick reference for some osx console commands i use more ore less frequently. Because i can’t remember all the magic.. ;)


Q: how to find files older than _n_ days ?

find . -type d -ctime +60


Q: how to delete them ?

$ find . -type d -ctime +60 | xargs rm -fr
# or use the -delete switch
$ find . -type d -ctime +60 -delete


Q: how to find the creator of a git branch ?

git for-each-ref \
--format='%(committerdate) %09 %(authorname) %09 %(refname)' | \
sort -k5n -k2M -k3n -k4n


Q: how to make a screenshot from the terminal

# capture images in format -t(ype) 'png' after waiting a -T(ime) of 5 seconds
# and open the -P(review) after storing them to ~/Desktop/
 
screencapture -t png -T 5 -P  ~/Desktop/screen1.png ~/Desktop/screen2.png
 
# -t the type of image (pdf, jpg, tiff)
# -T  the delay before the image is taken
# -P open images in preview window
# -M send images via mail
# -m only take the main monitor


Q: how to remove files or directories

# remove .svn folders
rm -rf `find . -type d -name .svn`
 
# remove .DS_Store files
rm -rf `find . -type f -name .DS_Store`


Q: how to start the trac-standalone server

tracd -r --port=8000 - --basic-auth="env,passwd,realm" $project/$env
 
# where:
# $project - the absolut path to your project folder (e.g. /Sites/project/)
# $env - the environment name (e.g. trac)
# $passwd - the absolut file to the .passwd file for the project 
            (e.g.  $project/$env/.htpasswd)
# $realm - something that you like (e.g. example.org, trac)


One Response to Snippet Collection

  1. pcqwabpr says:

    Pretty nice post. I just stumbled upon your weblog and wanted to say that I have truly enjoyed browsing your blog posts. After all I’ll be subscribing to your rss feed and I hope you write again very soon!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">