Posted on 03-28-2012 07:41 AM
Perhaps everyone already knows this, but I just found this to be awesome:
So, I'm mucking around in /var/db/dslocal/nodes/Default/users. There's lots of users' plist files. Now, I want to see the contents of one of these so I do a
defaults nobody.plist
and in response, I get
Domain nobody.plist does not exist
Well, "that's annoying," I think to myself, knowing I'm now going to have to type the full path to the .plist to see its contents.
Not so much, as it turns out.
Instead I did a
defaults read `pwd|nobody.plist`
and out spat my plist contents.
Not sure why I never tried that before, but I did just now and it's a good one to share. Sure there's a little bit more typing but it's better than the full path, IMHO.
Cheers.
Solved! Go to Solution.
Posted on 03-28-2012 12:22 PM
The following commands return different results:
defaults read `pwd`/nobody.plist
defaults read `pwd|nobody.plist`
They both offer output but the first one seems to return the proper results.
Posted on 03-29-2012 02:55 PM
Hey Everyone,
If if makes any of you feel better I just discovered this a while back ago recently. If you are in an open terminal session, and want to view a man page in a separate window, just type in the command, highlight it with the mouse, and then right click it and view man page. It will open up the man page in a nice new bright yellow window. I have NO CLUE when this became an available feature. I only discovered it after finally upgrading to Lion a few months back.
@ Joel -
I have been following your scripts here and checked out your website, good work man! Keep it up!
Thanks,
tom
Posted on 03-28-2012 10:02 AM
don't you mean `pwd`/user.plist?
that's standard *nix stuff, jj!
Posted on 03-28-2012 11:54 AM
Jared,
So, now we will expect you to be growing out your "Unix beard!"
-Tom
Posted on 03-28-2012 12:18 PM
D'oh. Holy cow how'd I miss that one. It still worked, even.
Don't look now but the emperor is wearing no clothes. haha
Posted on 03-28-2012 12:22 PM
The following commands return different results:
defaults read `pwd`/nobody.plist
defaults read `pwd|nobody.plist`
They both offer output but the first one seems to return the proper results.
Posted on 03-29-2012 11:39 AM
Another variation using the $() style, helps me with readability:
defaults read $(pwd)/nobody.plist
The Bonus for me was I always hated how defaults would complain when you put .plist at the end, but now I realize when you specify a path and it's not in domain lookup mode you can keep the .plist - I can clear out some ".plist" suffix trimming code from some scripts now :) Thanks
Posted on 03-29-2012 02:55 PM
Hey Everyone,
If if makes any of you feel better I just discovered this a while back ago recently. If you are in an open terminal session, and want to view a man page in a separate window, just type in the command, highlight it with the mouse, and then right click it and view man page. It will open up the man page in a nice new bright yellow window. I have NO CLUE when this became an available feature. I only discovered it after finally upgrading to Lion a few months back.
@ Joel -
I have been following your scripts here and checked out your website, good work man! Keep it up!
Thanks,
tom
Posted on 03-29-2012 04:13 PM
@Tom, dude that is sweet! Never knew you could open man pages like that. I've always just opened another tab or window in my Terminal to access those. I definitely need to start using that one! Thanks for the tip! :)
Posted on 03-29-2012 04:15 PM
Nifty!
Posted on 03-29-2012 04:25 PM
Haha, yeah I just discovered that maybe a month ago. I stumbled upon it by accident. Then I googled it and saw that OSXdaily.com had it documented. Need to visit that site more often I guess.
Though, I am not sure if it updates when the OS updates, so it still may be "best practices" when using Apple command line binaries to look the man page up on the dev website to see what has been changed in different versions, if anything at all.
Cheers!
Tom
Posted on 03-30-2012 07:43 AM
I don't get it - what type of scenarios would this be helpful?
Posted on 03-30-2012 09:05 AM
@jwojda Laziness...smartness...kind of like typing "sudo !!" to repeat the previous command using sudo.
Don
Posted on 05-04-2012 08:06 AM
A couple things.
@tlarkin grats on the new job
man page lookup is a nice find. I used to just open another Terminal window to do this before. Back in the day I used to do this to open them in Preview.
pman () {
/usr/bin/man -t "${1}" | /usr/bin/open -f -a /Applications/Preview.app
}
** now the fun project is to see if I can make it not yellow.
EDIT: there is a Window Setting for 'Man Page' in Terminal Prefs. Excellent :)
Posted on 05-04-2012 09:27 AM
@rmanly Thanks man, I am pretty stoked to be aboard here!
Also, here is something I wrote a long time ago. I actually stole the idea from someone else, but hey who is actually original these days?
function woman {
tmpfile="/tmp/man ${*}.pdf"
if [ ! -f "${tmpfile}" ]
then
man -t "${*}" | pstopdf -i -o "${tmpfile}"
fi
open "${tmpfile}"
}
Just put that in your ~/.bash_profile and run woman <man page> and it will open it in PDF. Called it woman because it is "prettier," than man.
Though now with Lion I prefer to use the right click method, works like a charm for me.
Posted on 05-04-2012 10:14 AM
prettier. HA!
It looks like Sal and the boys threw in a few new surprises.
http://www.macosxautomation.com/lion/terminal.html
Dragging a folder onto the Terminal icon could be a LOT faster in some cases than typing.
Also, I can see dragging a path to the tab bar being useful but I will probably forget and just open a new window or tab anyway.
Posted on 05-04-2012 02:38 PM
about man page viewing . . . bwana is really nice, give it a try:
http://www.bruji.com/bwana/
lets you open man pages in your browser by typing man:<command name> in the browser URL field.
It has a man page search interface in the browser, too.