Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/PrinceOfCookies/CookieOS/llms.txt

Use this file to discover all available pages before exploring further.

CookieOS enhances the CC:Tweaked shell at startup through startup/replacements.lua. Several built-in functions are wrapped or extended to add CookieOS-specific behaviour, and a handful of new helpers are injected directly into the shell and os globals. All changes are applied automatically at boot — no manual configuration is needed.

shell command

Running shell at the command prompt executes programReplacements/shell.lua, which prints the currently loaded OS versions in yellow text:
-- Running 'shell' in the terminal prints:
-- Main load: CraftOS 1.9
-- Co-load: CookieOS v2.2.5
The about command (programReplacements/about.lua) displays the same information, additionally appending the _HOST string to the main OS line.

os.version() enhancement

The original os.version() is wrapped to return two values: the base CC:Tweaked version string and the CookieOS co-version stored in the global cosv.
-- os.version() now returns two values
local main, co = os.version()
print(main) -- e.g. "CraftOS 1.9"
print(co)   -- e.g. "CookieOS v2.2.5"
Code that only reads the first return value continues to work exactly as before.

shell.setDir() enhancement

The built-in shell.setDir() is wrapped to write the current directory to os/data/lastDir.txt before navigating away, so that shell.lastDir() always has a valid destination to return to.
-- Navigate to a directory (logs the previous location automatically)
shell.setDir("/startup")

-- Return to the previously visited directory
shell.lastDir()
Passing false as the second argument suppresses the log write for that single call:
shell.setDir("/tmp", false)  -- navigate without updating lastDir.txt

shell.resolveProgram() override

shell.resolveProgram() is overridden to check /programReplacements/ before the standard program search path. This is the mechanism that makes all command replacements transparent — see Program Replacements Overview for the full details and source snippet.

Tab completion

The enhanced list and ls commands are registered with cc.shell.completion so that directory names are auto-completed when you press Tab:
shell.setCompletionFunction(
    "programReplacements/list.lua",
    completion.build(completion.dir)
)
shell.setCompletionFunction(
    "programReplacements/ls.lua",
    completion.build(completion.dir)
)

colors.grey alias

startup/replacements.lua adds colors.grey as an alias for colors.gray, ensuring scripts written with British spelling work without modification:
-- Both spellings now refer to the same color constant
term.setTextColor(colors.grey)   -- works
term.setTextColor(colors.gray)   -- also works

Summary of shell additions

FeatureDetails
shell commandPrints main OS + CookieOS co-version
os.version()Returns two values: main, co
shell.lastDir()Navigates to the previously visited directory
shell.setDir()Logs the current directory to os/data/lastDir.txt before changing
shell.resolveProgram()Checks /programReplacements/ before the default path
colors.greyAlias for colors.gray
Tab completionlist and ls complete directory names

Build docs developers (and LLMs) love