Monthly Archives: February 2011

Patterns for Using Theme Styles and Scripts

I’m bundling more functionality into my WordPress themes instead of into plugins these days. The best way I’ve found to handle extra scripts and styles is to use the functions wp_register_script, wp_enqueue_script, wp_register_style and wp_enqueue_style. These functions are used to setup the scripts and styles we’ll be using for our site. By sticking to these functions, WordPress will include these in the HTML when wp_head() is called, usually inside our header.php file.
Continue reading

How to setup git’s difftool on Windows

In this little recipe, we’re going to teach git on Windows how to run our own custom diff tool when we execute git difftool. The diff tool I’m using is WinMerge.

We’ll need to enter a few new configuration options on the command line:

git config --global diff.tool winmerge
git config --global difftool.winmerge.cmd "C:/git-difftool.bat \"$LOCAL\" \"$REMOTE\""
git config --global difftool.prompt false

Then create your wrapper script at C:/git-difftool.bat. Git will call this script when executing git difftool. That script should look like:

"C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -ub "$1" "$2"

Yes, this is using bash syntax in Windows shell! It works thanks to git, so you can execute git difftool from either the git shell or from Windows shell.

NOTE: backslashes won’t work in regular widows shell, but WILL in git shell — I know, weird! :)

There you are! Now you can enjoy git on Windows (ok, just kidding) AND on Linux!