Tuesday, 29 July 2008

Some pure old Mac fun

So i'm basically worn out of all these projects to hand out, and after an entire day completing the before last report, i've decided to take some free time and play with my Mac

I was so happy with the results that i want to share them with you all

1. Open in Terminal
Sometimes you're browsing with Finder and you find yourself in a relative long path; then you realize that you need to use a shell command on a file in that far away folder! oh the pain!
Open Terminal helps you with this task: if you move it to the application bar it will open a terminal in the folder selected/dragged/present in Finder! it comes with a contexual menu as well!

The only drawback is that it uses horrible icons, but you can change them and use these ones (follow the instructions reported) which are OpenTerminalHere ones

Open Terminal is much quickier than the other "open-here" apps because goes in the background, consuming no more than a Dashboard widget (but it works also without it, and it's alwasy a little faster than the others)

2. Open from Terminal
Here I'm reporting two tricks for when you are in the Terminal
The first one follows the above one: you can create an alias for calling the Open Terminal script that cds to the Finder active folder
alias cdf='eval `osascript /Applications/Utilities/OpenTerminal.app/Contents/Resources/Scripts/OpenTerminal.scpt `'
Put that line in your ~/.profile file and you're done (if you want to use it right away do source ~/.profile)
The second one is for opening the folder of where you are right now (in the Terminal)
open .
really that simple! open is a Mac utility that call the associated application for opening the what is given as argument, very useful; so if you "open file.txt" it will start TexEdit!

3. Cd Up
Last trick for the Terminal: when you are in a very long path (in Macs this happens often) if you go in another folder by mistake, you have to write the whole path again!
However if you put this simple line
alias up='cd "`env | grep OLDPWD | cut -f 2 -d =`" '
in your ~/.profile, you can return to your previous location just by calling up
This works also for any Linux distro :)

4. View in FullScreen
This is a nice AppleScript that opens a Finder Window in full screen in CoverFlow mode!
Very nice, but lacks of a nice icon! Fortunately you can use the lselect one found before.

5. Quicklook for source text files
So as i work mostly with VHDL, i wanted to have a way to have a quick preview of the source file, just like any other .c or .java file!

Well this is possible and it's also rather easy: inspired by this hint i started looking in every Info.plist files until i found the right one! The XCode one!

You just need to perform these simple steps and you'll be able to use Quicklook for .vhd and practically any other text file format.
  1. open /Developer/Applications/Xcode.app/Contents/Info.plist
  2. go to line 1439
  3. insert a line like vhd (replace vhd with the extension you need, i also added .dat and .cmm, but these two don't get highlighted)
  4. save the file and touch the application (touch /Developer/Applications/Xcode.app) to update the preference contents
  5. run a sudo qlmanage -r to restart the Quicklook daemon
6. X11 shorcuts like Mac shortcuts
Well, one of the reasons X11 is denigrated so much is that it has different cut/paste/save shortcuts, no drag and drop and different copy buffers

However this can be resolved very easily: just create a ~/.xmodmap file containg
keycode 63 = Control_L
keycode 60 = Alt_L
keycode 66 = Alt_L
clear mod1
clear Control
add mod1 = Alt_L
add Control = Control_L
In this way Copy and Paste will work like in Mac native apps, Cmd+c and Cmd+v, and all the shortcuts which required Control, will run with Cmd instead!


Well enough fun for now :)
It's time to go back working on GLX
Vittorio

No comments:

Post a Comment



All the projects here are under a Creative Commons 3.0 licence! You can use and distribute them as you like (just quote the author so he knows his work is not useless)!

If you wish to get in touch with me write at projectsymphony@gmail.com