1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

Fix dict and cdpath for 0.73 (#333)

* Update cdpath.nu

* Update dict.nu

* Update dict.nu

* Update cdpath.nu
This commit is contained in:
Kamil 2022-12-25 21:23:54 +01:00 committed by GitHub
parent 0fef4da080
commit fa1ce775d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View file

@ -2,16 +2,20 @@
def dict [...word #word(s) to query the dictionary API but they have to make sense together like "martial law", not "cats dogs"
] {
let query = ($word | str collect %20)
let link = (build-string 'https://api.dictionaryapi.dev/api/v2/entries/en/' ($query|str replace ' ' '%20'))
let output = (fetch $link |
rename word)
let w = ($output.word | first)
let link = ('https://api.dictionaryapi.dev/api/v2/entries/en/' + ($query|str replace ' ' '%20'))
let output = (fetch $link | rename word)
let w = ($output.word | first)
if $w == "No Definitions Found" {
echo $output.word
} else {
echo $output.meanings.definitions |
flatten | flatten |
select definition example
echo $output
| get meanings
| flatten
| select partOfSpeech definitions
| flatten
| flatten
| reject "synonyms"
| reject "antonyms"
}
}

View file

@ -20,18 +20,17 @@ def-env c [dir = ""] {
}
let complete_dir = if $complete_dir == "" {
error make -u {msg: "No such path"}
error make --unspanned {msg: "No such path"}
} else if (($complete_dir | path expand | path type) != "dir") {
error make -u {msg: "Not a directory"}
error make --unspanned {msg: "Not a directory"}
} else {
($complete_dir | path expand)
}
let-env PWD = $complete_dir
cd $complete_dir
}
# You need to have $env.CDPATH variable declared, my suggestion from config.nu:
# UNIX:
# let-env CDPATH = [".", $env.HOME, "/", ([$env.HOME, ".config"] | path join)]
# WINDOWS:
# let-env CDPATH = ["", $env.USERPROFILE, ([$env.USERPROFILE, "AppData\\Roaming\\"] | path join)]