Using dictionary from command line
I work in the terminal most of the times and I am just wondering if I could get all the information in terminal itself.
Any ideas? Thanks!
Message was edited by: kt.kthapar
iMac 27' Quadcore, Mac OS X (10.6.4)
You can make a difference in the Apple Support Community!
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
iMac 27' Quadcore, Mac OS X (10.6.4)
Linc Davis wrote:
you could install the POSIX 'dict' command (e.g. from MacPorts) which is a client for online dictionaries.
The suggestion given above launches Dictionary.app, which is apparently not what you want.
// insert code here...
NSLog(@"Hello, World!");
if(argc < 2)
{
printf("Usage: dict <word to define> ");
return -1;
}
NSString * search =
[NSString stringWithCString: argv[1] encoding: NSUTF8StringEncoding];
CFStringRef def =
DCSCopyTextDefinition(NULL,
(CFStringRef)search,
CFRangeMake(0, [search length]));
NSString * output =
[NSString
stringWithFormat:
@"Definition of <%@>: %@", search, (NSString *)def];
printf("%s", [output UTF8String]);
This is going in my .bash_profile 🙂
Works in Vi as well.
Great tip, thanks!
This may not be what you're looking for, but I find it handy sometimes: sp(){ egrep -hi "$*" /usr/share/dict/web* | less; }
Try Google (Note that this requires an internet connection to work 😉)
Phil Stokes wrote:
Great. All you need to do now is tell the OP how to do that in the command line
etresoft already gave the best answer to the OP's question in the 3rd post above.
Capisce? 😎
Thanks VikingOSX. I'll keep your advice in mind in future. What is the functionally ideal way to post Python code, for example, in Apple Support Communities?
Thank you very very much!!! I followed your directions and it works like a charm! I must say, this is even better than wn. Thanks again! 🙂
Hiroto,
Your code works with Python 2.7.10 on El Capitan 10.11.1.
Using dictionary from command line