Skip to content

Use Lua for Dynamic Configurations (.trushellrc) #87

Description

@AkshajSinghal

Discussed in #85

Originally posted by ElianThorne July 14, 2026
To compete with Bash, TruShell needs a configuration format that supports programming logic (like loops and if/else statements for dynamic prompts). Static formats like TOML or JSON won't cut it, and requiring users to compile Rust for basic config tweaks is impractical.
I propose embedding an ultra-fast, lightweight Lua engine into the core using the mlua crate.

Why Lua?

  • Performance: Sub-millisecond execution with near-zero memory footprint. No startup lag.
  • Simplicity: Clean syntax that is much easier to write than complex Bash scripting.
  • Proven Model: This is the same architecture used by Neovim and Starship.

Example User Config (.trushellrc):

local user = trushell.get_user()
if user == "root" then
    trushell.set_prompt("🔴 root -> ")else
    trushell.set_prompt("🟢 user -> ")end

trushell.set_alias("ll", "ls -la")

Implementation Plan

We can isolate the integration to src/config/lua_bridge.rs where we handle bindings and safely catch script errors so user bugs don't crash the shell. This also creates straightforward tasks for new contributors to map basic Rust structs into Lua functions.
Let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions