Use different home directories for GUI and shell access

Jan 03, '05 09:46:00AM

Contributed by: gadg

If you're like me and you regularly log into an OS X system from a remote location using Terminal, you most likely have a bunch of tools and scripts you regularly use. However, you also log on to the system using the GUI. When navigating the CLI, you don't want to see folders like 'Movies' and 'Library,' and when navigating the GUI, you don't want to see folders like bin and src.

So I figured I needed a way around that. Changing stuff using NetInfo, however, does not have the required effect. I consulted the experts on IRC, over at #macosx on EFnet and they threw me the ultra-simple solution of 'change your HOME environment variable.' Keep it simple, stupid. What you do is edit your .bashrc or (as in my case, .tcshrc) file to change the environment variable HOME to the new location, and then change to that directory. So:

setenv HOME /usr/home/gadg
cd $HOME
This will make me be in /usr/home/gadg. Referring to $HOME or ~ will point to /usr/home/gadg. However, referring to ~gadg will still point to /Users/gadg, as this is probably from the NetInfo database. Any improvements on this trick are more than welcome, of course!

[robg adds: I believe the bash version of the command is HOME=/usr/home/gadg; export HOME -- but I'm sure someone will correct me if I'm wrong!]

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041230192040887