shell (API)

From ComputerCraft Wiki
Jump to: navigation, search


The shell API allows you to interface with the shell. The shell API is only available when programs are ran from the shell or using shell.run/shell.openTab.

API

Grid disk.png  shell (API)
Function Return values Description
shell.exit() nil Exits the current shell.
shell.dir() string directory Returns the path to the working directory.
shell.setDir(string path) nil Sets the working directory.
shell.path() string path Returns the path.
shell.setPath(string path) nil Sets the path.
shell.resolve(string localPath) string absolutePath Resolves a local path to an absolute path.
shell.resolveProgram(string name) string absolutePath Resolves the absolute path to the program whose name you provided.
shell.aliases() table aliases Returns aliases.
shell.setAlias(string alias, string program) nil Sets an alias for program.
shell.clearAlias(string alias) nil Clears an alias.
shell.programs([boolean showHidden]) table programs Returns a table of files in the current directory and in all paths in shell.path.
shell.getRunningProgram() string path Returns the absolute path to the currently-executing program.
shell.run(string command [, string args1, string args2, ...]) boolean success Runs a command (program).
shell.openTab(string command [, string args1, string args2, ...]) number tabID Runs a program in another multishell tab. Requires version 1.6 or newer and an advanced system.
shell.switchTab(number tabID) nil Switches the multishell tab to tab with the given ID. Requires version 1.6 or newer and an advanced system.


Note that shell.run and shell.openTab concatenate any arguments they are given (with single space separator characters) before parsing the command, and as of ComputerCraft version 1.45, now also support a single string containing all parameters.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox