4.2.3 How to Set Preferences in New Images

Use cases:

  • you are tired of entering you name each time you modify classes in a new image.
  • you want all images to have a Monticello repository added.
  • put a nice image as wallpaper
  • change window title font
  • set proxy

The trick is to have a pharorc.st file written in Smalltalk which contains all what you want to do when opening an image.

For example, write a ~/.pharorc.st file:

 Author fullName: 'FirstnameLastname'.

MCRepositoryGroup default addRepository:
(MCDirectoryRepository new directory:
(FileDirectory on: '/home/user/pharo/repository')).

Form setBackgroundFromImageFileNamed: '/path/to/nice/image.png'.

Preferences setWindowTitleFontTo:
(LogicalFont familyName: 'DejaVu Sans' pointSize: 9).

addProxyException: '';
addProxyException: '';

Then write a shell script which loads pharorc.st. For example ~/bin/pharo (the directory must be in you $PATH environment variable)

 squeak $1 ~/.pharorc.st

dont forget to set the execution bit:

 chmod +x ~/bin/pharo

Then you can run your image with:

 pharo /path/to/my.image

Or associate the .image extension to the pharo script in your favorite desktop manager.

write an example for Windows

User Contributed Notes

btc (5 February 2012, 9:05 pm)

Define "New Images"

Does it work in the latest STABLE Pharo release - ie Pharo-1.3-OneClick ?

daliot.oh (9 April 2011, 6:37 am)

Found a typo.

the directory must be in you --> the directory must be in your

Add a Note

Licensed under Creative Commons BY-NC-SA | Published using Pier |