Mac OS X has its virtues. I hate pretty much every OS out there, but among the three that I use daily (Linux, OS X, and Windows), it’s not the one that I hate the most.
It does need its fair bit of fiddling to get to behave, though. Usually, it’s about getting general the UI and HIDs to behave like normal people would expect them to, but this evening I found myself having trouble with something entirely different. The $PATH in Mac OS X.
I was installing the OW LESS editor in Eclipse Indigo, and found that Eclipse couldn’t find my node binary (which is in /usr/local/bin on Mac OS X by default). I just kept getting an “env: node: No such file or directory” error when I tried to compile a .less file into a .css file.
This puzzled me, as it’s most definitely in my path. And not just in my path as set up in ~/.bashrc, but in the system-wide path as defined in /etc/paths. I could do “open /Applications/eclipse/Eclipse.app/” from iTerm and Eclipse would fire up with a proper PATH. It would actually use my path, including local stuff I have in ~/.scripts and ~/.apps.
Using Spotlight to launch it, however, would leave me with an Eclipse stranded on an island with no paths anywhere. In lieu of some way to launch apps using keyboard shortcuts, I always use Spotlight to launch apps — I don’t care for the dock and use it only to force close misbehaving apps.
So I asked Google, and she told me that for GUI apps to get a PATH, they need to get it from ~/.MacOSX/environment.plist. This file doesn’t exist by default, so you have to create it using “defaults write ~/.MacOSX/environment PATH ‘path1:path2:path3:etc’”, i.e. kinda feeding the BASH $PATH into this plist. So, the quick way to feed your path to the plist would be
defaults write ~/.MacOSX/environment PATH "`echo $PATH`"
From a terminal, of course. Well, this is all well, except it doesn’t quite work. You have to do a reboot for it to kick in, for one, but that’s just an annoyance. The real kicker is that — get this — from the terminal, processes (e.g. apps such as Eclipse.app, if opened using the “open” command), get the proper $PATH path. From the dock, apps don’t get that $PATH, they instead get the environment.plist PATH. Which is what I was expecting. Except — apps opened using Spotlight get neither $PATH nor environment.plist.
Apple. It Just Works. Except when It’s Just Broken.
To get apps launched from Spotlight to work, too, we need to go even deeper and create yet another non-existing file, /etc/launch.d. Again, this one needs a path in the same syntax as $PATH, so the fix is straightforward,
echo $PATH | sudo tee /etc/launchd.conf
Luckily, this doesn’t need a reboot, and we can launch Eclipse via Spotlight immediately and use the resources in our path.
I’ve create a BASH alias to do this for me,
alias path-sync='defaults write ~/.MacOSX/environment PATH "`echo $PATH`"; echo "setenv PATH $PATH" | sudo tee /etc/launchd.conf > /dev/null; echo "You must reboot before all of this kicks in."'
So from now on I can just issue “path-sync” from a terminal whenever I update my PATH and have the system behave as expected. Might forget it, though, so a root crontab entry might be in place, perhaps every day at 10:00?
# Make sure the PATH is sane all-round: 0 10 * * * su -c 'defaults write ~/.MacOSX/environment PATH "`echo $PATH`"' daniel; su -c 'echo "setenv PATH $PATH"' daniel > /etc/launchd.conf
So, this thing was seriously pissing me off. Every time I opened up Chrome, it’d try to open Kwallet for some annoying integration reasons. Sure, for some it’d probably be nice to use Kwallet for storing Chrome passwords, but for f**k’s sake, let me decide if that’s for me! I’m a LastPass user, not a dang-naggit Kwallet user!
So, anyway, searching for solutions doesn’t help. People mentioning google-chrome command line options like –password-store, hunting for flags or developer settings, some even suggest disabling Kwallet completely. Yeah, like that’s a good solution.
The Kwallet Manager app is of no use either. I can’t figure out what the “manage” part of that name is justified by. Basically, it’ll just list whatever apps are already “always allowed” to access the wallet, with no option to add new apps or change the rules for existing apps.
Well, luckily this is Linux, so a bit of settings file fiddling and some guesswork is usually rewarded. In this case, the solution is dead simple. Simply open up ~/.kde/share/config/kwalletrc in your favorite text editor (like Kate or nano in the konsole), and add these two lines to it:
[Auto Deny] kdewallet=Google Chrome
Voila. Log out and back in, or just fire up a Konsole and do “killall -9 kwalletd”, and Chrome won’t ever bug you again.
Now to fix the annoyance of Chrome always opening up on my secondary display…
So I’m living with Mac OS X ATM, at least until Kubuntu is fully compatible with my MacBook Air. It definitely has its niceness, but boy oh boy, is it also extremely difficult and inconsistent to work with. One thing that is really annoying is the complete disregard for how the rest of the world does keyboard shortcuts. Or even doing shortcuts in the first place. Never have I seen anyone use the mouse(pad) so much as when observing the average Mac OS X user. Working on this system out-of-the-box is such a drag, everything takes ages because standard keyboard functionality is missing (like Home, End, and Del keys), shortcuts are inconsistent – if even there, navigating a dialog without using your mouse pad is a no-go, Cmd+Tab disrespects spaces, is filled with minimized and tray apps, and creates new windows ad libitum.
Lots of good apps are out there to fix these usability issues, but I just learned how to add keyboard shortcuts for functionality for 3rd party applications, which is a built-in feature of Mac OS X, and really, really cool. I’m sharing it here.
Example: Aptana Studio 3 on Mac OS X supports PHP editing, but there’s no keyboard shortcut for looking up the definition for words in the language. You have to right-click, choose Commands, PHP, Documentation for Word. Not exactly great. This used to be Ctrl+F2 or something like that. But as it turns out, you can just add a shortcut yourself. Open up System Preferences > Keyboard, and choose the Keyboard Shortcuts pane. Chose Application Shortcuts in the left pane, and click the + button underneath the right pane. In the dialog choose the application you want to create a shortcut for, in this case “AptanaStudio3.app” (which you’ll probably have to find yourself – it wasn’t in the list when I did it). In the Menu Title field type in exactly (case-sensitive and all) the menu item you want to create a shortcut for, in this case “Documentation for Word”. Focus the Keyboard Shortcut field and press the keys you want to use for the shortcut. Click Add.
Works straight away!
I haven’t yet experienced what happens if there’s a name collision. I mean, like “New…” appearing in two different menus or something like that. So I don’t know how you would define the correct one you want in the Menu Title field. Time will tell. If you know how to do that, please leave a comment
I can’t claim to understand the reasoning behind getting rid of /var/log/messages in Natty. It’s the number one place to start looking when something goes wrong, and one of the first places people asking for community help are told to go look and report back in order to debug some situation. Either way, to right this wrong is definitely very easy, so just fire up a terminal and type:
you@your-puter:~$ sudo nano /etc/rsyslog.d/50-default.conf
In nano, find the commented out lines mentioning “/var/log/messages”, and uncomment them.
Tip: Search by pressing Ctrl+W, then type in messages and press enter.
You should be uncommenting four lines, and ending up with this:
*.=info;*.=notice;*.=warn; auth,authpriv.none; cron,daemon.none; mail,news.none -/var/log/messages
Save it and exit (Ctrl+O, Enter, Ctrl+X), then restart the syslog daemon:
you@your-puter:~$ sudo service rsyslog restart
That’s it. /var/log/messages is back
I’m currently moving about a whole bunch of smaller files in Windows 7 (about 400,000 files). I was getting frustrated with the abysmal rate at which Windows is able to move files around. Even moving just one folder into another one causes Explorer to start “discovering” the entire source dir, which is utterly pointless in the first place as there’s just one node to consider and to relink in the MFT. One wonders why it always does that. It didn’t do so before Vista.
Anyway – adding injury to insult, these files need to be imported in and processed by an application which is rather poorly written, making it run out of memory when it is fed much more than 4,000 files at a time. So, I have to move batches of about 4,000 files into separate folders before importing them, and to do this I have to use Explorer. The move operations, as mentioned, are incredibly slow, maxing out at 25 items per second, sometimes dropping to 5 items/sec, generally hovering at about 15 items/sec. I was wondering if the problem was the files lists in the source and target Explorer windows being continually refreshed as items were moved in and out of them, and so tried to navigate away from them, even closing the windows entire, without effect.
Then, by accident, I discovered that if I selected a batch of files from the bottom of the list in the source window, the move operation was massively faster, running at 350-500 items/sec! That’s a performance factor of ~ 14 to 100, in other performing, compared to the previous runs, at between 1,400% and 10,000% effectiveness. Go figure!
Not having access to the Windows source code, one can only guess at what kind of code disaster lies behind this behavior. But regardless, remembering this trick can prove very helpful when you don’t feel like spending an entire day looking a green bars very slowly moving east.
These issues, and the effect of this trick, seem to happen according to Windows’ current mood, though. Sometimes you get to drag-and-drop a folder with 200,000 files into another folder instantly, at other times it’ll spend 30 seconds examing a 100-file folder. Similarly, sometimes (about 1 in 4 so far) the forementioned trick has no effect, and you’re looking at green bars again. Your mileage may vary
- Getting Something Like a Global PATH in Mac OS X
- How to Disable Kwallet Integration in Google Chrome
- If This Ain’t Art, I Don’t Know What Is
- Creating Missing Keyboard Shortcuts in Applications on Mac OS X
- Get Back /var/log/messages in (K)ubuntu 11.04, 11.10, 12.04, 12.10, and Counting…