Skip to content

Latest commit

 

History

History
106 lines (52 loc) · 1.73 KB

File metadata and controls

106 lines (52 loc) · 1.73 KB

Home > bitburner > UserInterface > alias

UserInterface.alias() method

Programmatically sets an alias.

Signature:

alias(alias: string, substitution: string, global?: boolean): void;

Parameters

Parameter

Type

Description

alias

string

The keyword to set.

substitution

string

The substitution to run.

global

boolean

(Optional) Whether the alias should be set as a global alias. Global aliases replace all examples of the alias with the substitution string.

Returns:

void

Remarks

RAM cost: 0 GB

Programmatically sets an alias. This is functionally equivalent to if you typed ``alias ${alias}=${substitution}`` in the terminal. This function throws an error if alias/substitution are empty strings after leading and trailing whitespace are removed. It also throws if alias has any invalid characters (not alphanum or |!%,@-).

Only one alias can be set for a particular context; global aliases will overwrite nonglobal aliases silently and vice versa.

Example

File: script.js

export async function main(ns){
   ns.alias("nuke", "run NUKE.exe"); // Equivalent to typing "alias nuke="run NUKE.exe"
   ns.alias("worm", "HTTPWorm.exe", true); // Equivalent to typing "alias -g worm="HTTPWorm.exe"
}