A small shell with Lua inside.
Familiar shell syntax at the prompt. Real Lua tables between pipeline stages. Zero runtime dependencies.
wisp
~/wisp
in-process / 0 forks
- lines of C++17
- 3,668
- stripped binary
- 420 KB
- startup time
- 0.55 ms
- static Lua 5.4
- Linux & macOS
Structured in-process. Plain text at the edge.
Consecutive Lua stages pass tables directly on the Lua stack. Crossing into a binary on $PATH converts to key=value lines automatically.
Native Lua run
files
where name ~= %.cpp$
sort_by size desc
Lua table on stack
{ name = "executor.cpp", size = 52770 }
External binary
| wc -l
or
| grep main
key=value text
name=executor.cpp size=52770
No config DSL. Just Lua 5.4.
Every global function in ~/.config/wisp/init.lua becomes a shell command with access to sh(), capture(), and wisp.status.
-- ~/.config/wisp/init.lua
function prompt()
local branch = capture("git branch --show-current 2>/dev/null")
local git = branch ~= "" and (" (" .. branch .. ")") or ""
local err = wisp.status ~= 0 and (" [" .. wisp.status .. "]") or ""
return "wisp" .. git .. err .. "> "
end
-- Plain command: first arg is pipeline input (nil if none), rest are shell args
function greet(_, name)
print("hello, " .. (name or "world"))
end
-- Aliases are regular functions calling sh()
function ll()
sh("ls -la")
end
-- examples/recipes.lua (load with: source examples/recipes.lua)
function top_mem(_, n)
return take(sort_by(procs(), "mem_kb", "desc"), tonumber(n) or 10)
end
function git_log(_, n)
local out, rc = capture("git log -n " .. (tonumber(n) or 15) .. " --format='%h\t%an\t%ad\t%s' --date=short")
if rc ~= 0 or out == "" then return {} end
local rows = {}
for _, line in ipairs(lines(out)) do
local hash, author, date, msg = line:match("([^\t]*)\t([^\t]*)\t([^\t]*)\t(.*)")
if hash then
rows[#rows + 1] = { hash = hash, author = author, date = date, message = msg }
end
end
return rows
end
function json_get(_, url)
if not url then error("usage: json_get <url>") end
local out, rc = capture("curl -fsSL '" .. url:gsub("'", "'\\''") .. "'")
if rc ~= 0 then error("curl failed (" .. rc .. ")") end
return from_json(out)
end
Sources
files- Directory entries with name, type, size, and mtime
procs- Running processes with pid, name, state, and mem_kb
lines- Split text or external stdout into a Lua string list
Transforms
where- Filter rows with ==, !=, ~=, gt, ge, lt, or le
sort_by- Sort records by field name ascending or descending
cols- Project selected columns while keeping row order
take- Keep the first N rows from a table
skip- Drop the first N rows from a table
count- Return the number of items in a pipeline table
Formats
from_json- Decode JSON input into native Lua tables
to_json- Encode Lua tables into compact JSON text
from_csv- Parse headered CSV rows into keyed records
Install in one line.
Static-Lua binaries run across distros with no shared library mismatches.
curl -fsSL https://wisp-shell.pages.dev/install.sh | sh