Repository navigation
script
use script (also use script mode) makes a program a script: no hints (as use relaxed), and the scripting words
of the modules os, file, net and shell without further use.
use script
ls ~/
A path needs no quotes: ~ is the home folder, ./ and ../ start from the working directory, / from the root.
cat ~/notes.txt
cd /tmp
x = ./songs/a.wav
/ starts a path where no operand stands before it, after a function or after another path: ls /tmp lists,
cp /a/x /b copies, while width /height with a variable width divides.
Each Unix command is a warp word with a warp result, a list or a text you can keep working with:
for name in ls ./src { print name } // ls: the names in a folder, hidden ones left out
print head(./notes.txt, 3) // the first lines, a list; tail the last ones
print wc ./notes.txt // {lines: 3, words: 5, bytes: 20}
print grep("^todo", ./notes.txt) // the lines a regular expression matches
| word | does | result |
|---|---|---|
ls folder |
names in a folder (default .), sorted, no hidden ones |
list |
pwd, cwd
|
the working directory | text |
cd folder |
changes the working directory (default ~) |
the new one |
cat file |
a file's text (read) |
text |
echo x |
prints, as print
|
|
mkdir folder |
makes it, with the folders above it | ø |
cp from, to / mv from, to
|
copies / moves a file, into a folder keeping its name | ø |
touch file |
makes it empty if missing, else sets its time | ø |
head file, n / tail file, n
|
the first / last n lines (default 10) | list |
wc file |
{lines words bytes} |
map |
grep pattern, file |
the matching lines | list |
sort ./file / unique ./file
|
the lines sorted / without repeats | list |
find ./folder, "*.warp" |
the paths below a folder whose name matches | list |
size ./path |
bytes of a file or a whole folder | int |
info path |
{size modified kind}, modified in ms like clock()
|
map |
which "git" |
the program's path, ø if none | text |
open file |
the file in its app (natively only) | ø |
rm file |
moves it to the Trash | ø |
sort, unique, find and size take a path written without quotes, or a variable holding one, and a list
otherwise: sort ./names.txt sorts the file's lines, sort [3 1 2] the list. A path in quotes is a text, so
sort "names.txt" sorts its letters; sort_lines, unique_lines, find_files and file_size take either.
curl url and wget url are fetch url.
rm has guard rails: one file or an empty folder, moved to the Trash; never a pattern (for f in glob("*.txt") { rm f }), a full folder, the root, the home folder, or the working directory and the folders above it.
Anything else runs in the shell itself: command("ls | wc -l") gives its output as text.
In the browser the words work on the page's files; cd, open and command run natively only.