import "$url"The core import function downloads the $url parameter and
caches it to the file system. Finally, it sources
the downloaded script.
import_file "$url"Uses the same download and caching infrastructure as import, but prints the
local file path instead of sourcing the file. This enables working with arbitrary
files such as scripts from other languages, simple data files, binary files, etc.
import_cache_dir "$name"Returns the operating system specific path to the cache directory for the given
$name. This function honors the XDG Base Directory
Specification
by utilizing the $XDG_CACHE_HOME environment variable, if defined. Otherwise it
falls back to using:
$HOME/Library/Caches on macOS$LOCALAPPDATA on Windows$HOME/.cache everywhere elseimport_cache_dir_importReturns the operating system specific path to the cache directory that files
imported using import are written to. This function returns the contents the
$IMPORT_CACHE environment variable, if defined. Otherwise it returns the result
of import_cache_dir import.sh.
#!/usr/bin/env importimport "https://import.sh/string@0.2.0"
echo InPuT | string_upper# INPUT#!/usr/bin/env import
ruby "$(import_file https://import.sh/importpw/import/test/static/sum.rb)" 9 10 11 12# 42#!/usr/bin/env import
import_cache_dir example# /Users/nate/Library/Caches/example
XDG_CACHE_HOME=/cache import_cache_dir example# /cache/example#!/usr/bin/env import
import_cache_dir_import# /Users/nate/Library/Caches/import.sh
IMPORT_CACHE=/tmp import_cache_dir_import# /tmp