xplr.util.version

Get the xplr version details.

Type: function() -> { major: number, minor: number, patch: number }

Example:

xplr.util.version()
-- { major = 0, minor = 0, patch = 0 }

xplr.util.dirname

Get the directory name of a given path.

Type: function( path:string ) -> path:string|nil

Example:

xplr.util.dirname("/foo/bar")
-- "/foo"

xplr.util.basename

Get the base name of a given path.

Type: function( path:string ) -> path:string|nil

Example:

xplr.util.basename("/foo/bar")
-- "bar"

xplr.util.absolute

Get the absolute path of the given path by prepending $PWD. It doesn't check if the path exists.

Type: function( path:string ) -> path:string

Example:

xplr.util.absolute("foo/bar")
-- "/tmp/foo/bar"

xplr.util.explore

Explore directories with the given explorer config.

Type: function( path:string, config:Explorer Config|nil ) -> { node:Node... }

Example:


xplr.util.explore("/tmp")
xplr.util.explore("/tmp", app.explorer_config)
-- { { absolute_path = "/tmp/a", ... }, ... }

xplr.util.shell_execute

Execute shell commands safely.

Type: function( program:string, args:{ arg:string... }|nil ) -> { stdout = string, stderr = string, returncode = number|nil }

Example:

xplr.util.shell_execute("pwd")
xplr.util.shell_execute("bash", {"-c", "xplr --help"})
-- { stdout = "xplr...", stderr = "", returncode = 0 }

xplr.util.shell_quote

Quote commands and paths safely.

Type: function( string ) -> string

Example:

xplr.util.shell_quote("a'b\"c")
-- 'a'"'"'b"c'

xplr.util.from_json

Load JSON string into Lua value.

Type: function( string ) -> value

Example:

xplr.util.from_json([[{"foo": "bar"}]])
-- { foo = "bar" }

xplr.util.to_json

Dump Lua value into JSON (i.e. also YAML) string.

Type: function( value ) -> string

Example:

xplr.util.to_json({ foo = "bar" })
-- [[{ "foos": "bar" }]]

xplr.util.to_json({ foo = "bar" }, { pretty = true })
-- [[{
--   "foos": "bar"
-- }]]

xplr.util.from_yaml

Load YAML (i.e. also JSON) string into Lua value.

Type: function( string ) -> value

Example:

xplr.util.from_yaml([[{foo: bar}]])
-- { foo = "bar" }

xplr.util.to_yaml

Dump Lua value into YAML string.

Type: function( value ) -> string

Example:

xplr.util.to_yaml({ foo = "bar" })
-- "foo: bar"