-
All replies
-
Helpful answers
-
-
Dec 12, 2010 2:00 PM in response to kt.kthaparby Linc Davis,Not possible with the built-in dictionaries as far as I know, but 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. -
Dec 12, 2010 2:56 PM in response to Linc Davisby etresoft,Linc Davis wrote:
you could install the POSIX 'dict' command (e.g. from MacPorts) which is a client for online dictionaries.
Ugh! How crude!The suggestion given above launches Dictionary.app, which is apparently not what you want.
Yes indeed. Sorry for not paying more attention.
Since you work in terminal most of the time, a little Xcode can't hurt.
1) Create a new Foundation Command Line Tool in Xcode.
2) Replace the lines:
// insert code here...
NSLog(@"Hello, World!");
with
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]);
3) Add the CoreServices framework to the project. Right/command click on "External Frameworks and Libraries", choose "Add..", choose "Existing Frameworks..", choose "CoreServices.framework", and click "Add".
4) Build
5) Enjoy -
Feb 25, 2011 7:39 AM in response to kt.kthaparby matthewcornell,I can understand wanting to do this in Terminal, but really, as a power user, Spotlight for looking up words is very fast: Command-space to open spotlight, type the word, command-down or control-n to the dictionary icon, return. When done, command-tab to get back to Terminal. Easy! -
Feb 26, 2011 11:39 AM in response to kt.kthaparby Seph,If you don't mind using the mouse, you can mouse over the word, then press 'cmd-ctrl-d' to get a drop-down of the definition. -
Mar 22, 2014 8:39 PM in response to etresoftby mklement0,Thanks for the great ObjC code.
- `CFRelease(def);` should be added at the end to release the string returned by `DCSCopyTextDefinition()`.
- As of Xcode 5.1 on OS X 10.9.2 with ARC you also need `__bridge` cast qualifiers: `
(__bridge CFStringRef)` and `(__bridge NSString*)`.
- Also, adding the CoreServices framework (in addition to Foundation) appears not to be necessary.
`
-
Mar 23, 2014 5:26 PM in response to kt.kthaparby VikingOSX,One could put the following code in their ~/.bashrc file as a shell function.
dict () {
curl dict://dict.org/d:"${1}"
}
Then:
source .bashrc
dict Apple | more
Alternative using SpotLight
Use command+Space will open Spotlight. Put in the word you want to look up in the Apple Dictionary App. The results appear far down on the Spotlight results. Press command+L to jump to the dictionary entry and open the result in a Window, or command+D to open the Apple Dictionary App referencing the Spotlight word.
-
-
Mar 23, 2014 7:26 PM in response to VikingOSXby Phil Stokes,VikingOSX wrote:
One could put the following code in their ~/.bashrc file as a shell function.
dict () {
curl dict://dict.org/d:"${1}"
}
Then:
source .bashrc
dict Apple | more
For those considering this, note that
i. it requires an internet connection to work
ii. it'll be as fast (or slow) as your connection + the server respond time.
While it's an interesting way to do it, it seems wasteful to go online to query a dictionary when there's one instantly accessible sitting on your hard drive.
-
-
Mar 23, 2014 8:16 PM in response to Phil Stokesby VikingOSX,Phil,
It was another approach to the post theme. Personally, I keep the Apple Dictionary in my Dock, and use it often. As always, there are multiple solution forms, and individual workflow determination comes into play.
-
Mar 24, 2014 3:44 AM in response to VikingOSXby Phil Stokes,Sure, as I said I thought the solution was quite interesting from a technical point of view. Always good to know of different ways to skin a cat. I was just pointing out some practical drawbacks is all.
In fact my own workflow is your second suggestion. Accessing Spotlight from the keyboard is a very fast way to accomplish a lot of things in OS X, not just the dictionary.
-
Mar 24, 2014 5:33 AM in response to Phil Stokesby Tony T1,Phil Stokes wrote:
For those considering this, note that
i. it requires an internet connection to work
So, if you don't have an internet connection, you wouldn't be reading this
Anyway, a better note is not to use any scripts that you don't understand
(i.e., if you don't know what curl is, then man curl before using)
-
Mar 24, 2014 6:10 AM in response to kt.kthaparby Cole Tierney,This may not be what you're looking for, but I find it handy sometimes: sp(){ egrep -hi "$*" /usr/share/dict/web* | less; }