Posts Tagged ‘osx’

Automate pdf preview when using vi to edit latex on OSX.

Friday, March 26th, 2010

You can add the following to your .vimrc in order to have vi automaticly update and show the pdf version of the LaTex .tex file you are currently editing. The CursorHold part triggers updating after a set amount of inactivity, while the BufWritePost part triggers an update before each save (when you type :w ). This is based on a post doing the same for ubunu.

Note (deprecated now due to the edit below): the ” !open -a Terminal” is just a work-around since i didn’t find a way to make Preview.app update in the background (aka not steal the focus).

EDIT 2010-03-29: Since Guillermo pointed out how to do the update properly i changed my .vimrc entry. But i left the old line in as a comment.

""""""""""""""""""""""""""""""""""""""""""""""""""
" for LaTeX files
""""""""""""""""""""""""""""""""""""""""""""""""""
au BufEnter *.tex set autowrite "save before making PDF"
au BufEnter *.tex set updatetime=500 "wait ms"
au BufEnter *.tex set makeprg=pdflatex\ -halt-on-error\ %\ >&\ /dev/null

"make the file after specified time of not moving and after every save"
au CursorHold *.tex call UpdateFile()
au BufWritePost *.tex call UpdateFile()

function! UpdateFile()
  silent make
    !open -g %<.pdf  "update view in preview"
    " following comment line was needed before i learned about the -g option "
    " !open -a Terminal   switch back to vi assuming you run it in Termial"
    redraw! "remove artifacts during save"
    endfunction

au BufRead *.tex silent !open -g -a preview %<.pdf

Building GTK on OSX and Problems with libiconv

Sunday, March 21st, 2010

Ok, this i maybe a bit special, but maybe it helps someone out there. I am on the way to build GTK+ on OSX using “jhbuild”, following a good instruction:

http://live.gnome.org/GTK%2B/OSX/BuildInstructions

Coming to the point where to build glib, the process exits with following error message:

gconvert.c:55:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv

First the library is on the system; we can find it easily with

$ locate libiconv

Trying to link the system library to the one found provided by xcode failed into strange error messages. So i decided to re-build the libiconv by hand as “root” from source:

$ cd /usr/local/src/

Getting from http://www.gnu.org/software/libiconv/ the latest version (currently 1.13.1) with

$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
$ tar zxvf libiconv-1.13.1.tar.gz

Now the configuring, make and install phase:

$ ./configure
$ make
$ make install

This builds the latest version of libiconv for me. Final step was to replace the current version in

/usr/lib

and to go on with the GTK+ process.

Check Mac battery health from Terminal.app

Thursday, October 23rd, 2008

So this goes out to all the shell-lovers using a Mac. If you want to know how old your battery is, how many charge-recharge cycles it went through, how much of it’s original capacity has degraded, etc…

Just open your Terminal and type:

ioreg -w0 -l | grep Capacity | cut -d " " -f 17-50

Using the shell to create disk-images on OSX.

Thursday, August 21st, 2008

All these GUI stuff drives me crazy – sometimes. I just wanted to burn a CD during working on my old iBook. Do I really need to install some new program or do I have to use some ‘on-board’ tool and click-here-click-there? Most of you will have installed some tool and you just do a click-and-drop, but I don’t and anyway I am more used to the tools ‘cdrecord’ and ‘mkisofs’ on Linux. Here is how you can create and burn disk-images on OSX with a shell. The shell command for this kind of task is

hdiutil verb [options]

So, this tool can do a lot for you e.g. possible ‘verbs’ are create, convert, burn, etc… I will just write what i did to burn a CD: First I created a new disk-image

hdiutil create -format UDTO -srcfolder folderWithData diskImageWithData.dmg

uhh, and now just burn it!

hdiutil burn diskImageWithData.img

Ok, thats cool. You can also eject, mount and convert disk-images. For example you start with your backup SPARSE disk-image and convert it to a ISO image and the burn it or whatever. Have a look at the man-pages for all verbs and options.