diff --git a/cool_oneliners/dict.nu b/cool_oneliners/dict.nu new file mode 100644 index 0000000..570a0fe --- /dev/null +++ b/cool_oneliners/dict.nu @@ -0,0 +1,12 @@ +#As the name suggests, the function returns you the definition and example of the sought English word +#(or breaks if it can't find the word because the API uses different columns for successful and invalid searches) + +#usage: dict word +#usage: dict "word with space" + +def dict [word: string] { + let link = (build-string 'https://api.dictionaryapi.dev/api/v2/entries/en/' ($word|str find-replace ' ' '%20')) + fetch $link | + get meanings.definitions| + select definition example +}