Home > bitburner > UserInterface > alias
Programmatically sets an alias.
Signature:
alias(alias: string, substitution: string, global?: boolean): void;|
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
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.
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"
}