OS
OS related functions
cwd?
Gets the current working directory.
none
returns uri representing the current working directory
cc os
print cwd?
ls |for { .print }
ls\ 'files |for { .print }
host-info? -> "hostname" |print
load-avg? -> "1" |print
virtual-memory? -> "total" |print
disk-usage? |print
processes? |first |print
does-exist
Checks if a file or directory exists.
path uri representing the file or directory to check
returns boolean: true if exists, false if not
cc os does-exist %main.rye
; returns true
cd
Changes the current working directory.
path uri representing the directory to change to
returns the same uri if successful
env?
Gets the value of an environment variable.
variable_name string containing the name of the environment variable
returns string containing the value of the environment variable
mkdir
Creates a new directory.
path uri representing the directory to create
returns the same uri if successful
mktmp
Creates a new temporary directory.
none
returns uri representing the created temporary directory
rm
Removes a file or empty directory.
path uri representing the file or empty directory to remove
returns the uri if successfulTags: #file #delete
rmdir
Removes a directory and all its contents recursively.
path uri representing the directory to remove (including contents)
returns the uri if successfulTags: #file #delete
cp
Copies a file to a new location.
source uri representing the source file
destination uri representing the destination file
returns destination uri if successfulTags: #file #copy
file-info?
Gets detailed information about a file or directory.
path uri representing the file or directory
returns dict with keys: name, size, mode, mod-time, is-dirTags: #file #info
is-dir
Checks if a path is a directory. Fails if the path does not exist.
path uri representing the path to check
returns boolean: true if path is a directory, false otherwise. Fails if the path does not exist.Tags: #file #check
is-file
Checks if a path is a regular file (not a directory). Fails if the path does not exist.
path uri representing the path to check
returns boolean: true if path is a regular file, false otherwise. Fails if the path does not exist.Tags: #file #check
home-dir?
Gets the current user's home directory.
none
returns uri representing the user's home directoryTags: #file #directory
tmp-dir?
Gets the system's default temporary directory.
none
returns uri representing the system's temporary directoryTags: #file #directory
glob
Returns files matching a glob pattern.
pattern string containing a glob pattern (e.g., "*.txt", "data/*.csv")
returns block of uris matching the patternTags: #file #search
mv
Moves or renames a file or directory.
source uri representing the source file or directory
destination uri representing the destination file or directory
returns destination uri if successful
ls
Lists files and directories in the current directory.
none
returns block of uris representing files and directories in the current directory
ls\
Lists files or directories with absolute paths when possible. If argument is a file-uri, lists that directory (or returns failure if not a directory). Otherwise filters current directory: 'dirs' for directories only, 'files' for files only, a string for partial name matching, or a regexp to match names.
filter file-uri to list directory, word 'dirs' or 'files' to filter by type, string for partial name matching, or regexp to match names
returns block of uris representing filtered files or directories in the specified directory or current directory
ls\dirs
Lists only directories in the current directory.
none
returns block of uris representing directories in the current directory
ls\files
Lists only files (non-directories) in the current directory.
none
returns block of uris representing files (non-directories) in the current directory
ls\dirs\
Lists directories in the current directory with filtering. Use a string for partial name matching, or a regexp to match names.
filter string for partial name matching, or regexp to match names
returns block of uris representing filtered directories in the current directory
ls\files\
Lists files (non-directories) in the current directory with filtering. Use a string for partial name matching, or a regexp to match names.
filter string for partial name matching, or regexp to match names
returns block of uris representing filtered files (non-directories) in the current directory
symlink
Creates a symbolic link.
path uri representing source path
link uri representing link path to create
returns link uri if successfulTags: #file #link
is-symlink
Checks if a path is a symbolic link. Fails if the path does not exist.
path uri representing a path to check
returns boolean: true if path is a symbolic linkTags: #file #check
readlink
Reads the target of a symbolic link.
path uri representing a symbolic link
returns uri representing the target of the symlinkTags: #file #link
chmod
Changes file or directory permissions.
path uri representing file or directory path
mode integer representing file mode (e.g., 0755)
returns path uri if successfulTags: #file #permissions
abs-path
Returns the absolute path for a given path.
path uri representing file or directory
returns string representing the absolute pathTags: #file #path
dirname
Returns the directory part of a path.
path uri representing a path
returns uri representing the directory containing the pathTags: #file #path
basename
Returns the filename part of a path.
path uri representing a path
returns string representing the filename part of the pathTags: #file #path
file-ext
Returns the file extension of a path (including the dot).
path uri representing a file path
returns string representing the file extension (including the dot)Tags: #file #path
join-path
Joins path elements into a single path.
paths uri or block of uris to join
returns uri representing the joined pathTags: #file #path
whoami
Returns the current user's username.
none
returns string representing the current user's usernameTags: #system #user
which
Finds the path to an executable command.
command string representing the command to check
returns uri representing the path to the executable, or error if not foundTags: #system #command
cp-r
Recursively copies a directory and all its contents.
source uri representing source directory
destination uri representing destination directory
returns destination uri if successfulTags: #file #copy #recursive
mkdir-p
Creates a directory and any necessary parent directories.
path uri representing directory path to create
returns path uri if successfulTags: #file #directory
host-info?
Gets information about the host system.
none
returns dictionary containing information about the host system (hostname, uptime, OS, etc.)
users?
Gets information about users currently logged into the system.
none
returns table containing information about users (user, terminal, host, started)
load-avg?
Gets the system load average over the last 1, 5, and 15 minutes.
none
returns dictionary with keys "1", "5", and "15" representing load averages
virtual-memory?
Gets information about virtual memory usage.
none
returns dictionary containing information about virtual memory (total, free, used-percent)
disk-usage?
Gets disk usage information for all partitions.
none
returns table containing disk usage information for all partitions
pids?
Gets a list of all process IDs currently running.
none
returns block of integers representing process IDs
processes?
Gets detailed information about all running processes.
none
returns table containing detailed information about all running processes
process
Gets detailed information about a specific process by PID.
pid integer process ID
returns dictionary containing detailed information about the specified process
lookup-address
Performs a reverse DNS lookup to get hostnames for an IP address.
ip string containing an IP address
returns block of strings containing hostnames associated with the IP
lookup-ip
Performs a DNS lookup to get IP addresses for a hostname.
hostname string containing a hostname
returns block of strings containing IP addresses associated with the hostname
write\clipboard
Writes a string value to the system clipboard.
value string to write to the clipboard
returns the same string if successful
read\clipboard
Reads the current contents of the system clipboard.
none
returns string containing the current contents of the clipboard
tgz
Creates a .tar.gz archive from a file or directory.
source uri representing the file or directory to archive
destination uri representing the output .tar.gz file
returns destination uri if successfulTags: #archive #compress
un-tgz
Extracts a .tar.gz archive to a directory.
source uri representing the .tar.gz file
destination uri representing the output directory
returns destination uri if successfulTags: #archive #extract
zip
Creates a .zip archive from a file or directory.
source uri representing the file or directory to archive
destination uri representing the output .zip file
returns destination uri if successfulTags: #archive #compress
unzip
Extracts a .zip archive to a directory.
source uri representing the .zip file
destination uri representing the output directory
returns destination uri if successfulTags: #archive #extract
find
Creates a new file finder starting from the given path(s).
path uri or block of uris representing starting paths
returns native finder objectTags: #find #files
finder//min-depth!
Sets the minimum depth for file traversal.
finder native finder object
depth integer minimum depth
returns native finder object (for chaining)Tags: #find #filter
finder//max-depth!
Sets the maximum depth for file traversal.
finder native finder object
depth integer maximum depth
returns native finder object (for chaining)Tags: #find #filter
finder//type
Filters results by type: 'file (or "f") for files, 'dir (or "d") for directories.
finder native finder object
type word 'file or 'dir (or string "f" or "d")
returns native finder object (for chaining)Tags: #find #filter
finder//name
Filters results by file name using a glob pattern.
finder native finder object
pattern string glob pattern (e.g., "*.go", "test_*")
returns native finder object (for chaining)Tags: #find #filter
finder//whole-name
Filters results by full path using a glob pattern.
finder native finder object
pattern string glob pattern for the whole path
returns native finder object (for chaining)Tags: #find #filter
finder//regex
Filters results by regular expression on the full path.
finder native finder object
regex native regexp object
returns native finder object (for chaining)Tags: #find #filter
finder//empty
Filters for empty files or directories.
finder native finder object
returns native finder object (for chaining)Tags: #find #filter
finder//eval
Executes the find operation and returns matching paths as uris.
finder native finder object
returns block of uris representing found files/directoriesTags: #find #execute
file-size
Gets the size of a file in bytes.
path uri representing the file
returns integer size in bytesTags: #file #size
touch
Creates a file if it doesn't exist, or updates its access time if it does.
path uri representing the file to touch
returns path uri if successfulTags: #file #create
hardlink
Creates a hard link to a file.
source uri representing the source file
link uri representing the hard link to create
returns link uri if successfulTags: #file #link
count-dir
Counts the number of files and directories in a directory.
path uri representing the directory (optional, defaults to current dir)
returns integer count of itemsTags: #file #count
pid
Gets the current process ID.
none
returns integer process IDTags: #system #process
ppid
Gets the parent process ID.
none
returns integer parent process IDTags: #system #process
sleep
Sleeps for the specified number of seconds.
duration integer seconds to sleep
returns integer seconds sleptTags: #system #time
tmux-available?
Checks if tmux is available on the system.
none
returns boolean indicating if tmux is availableTags: #tmux #check
tmux-new-session
Creates a new tmux session with the given name using gotmux library.
session-name string name for the new session
returns native tmux session objectTags: #tmux #session
tmux-list-sessions
Lists all tmux sessions using gotmux library.
none
returns block of native tmux session objectsTags: #tmux #session #list
tmux-get-session
Gets a tmux session by name using gotmux library.
session-name string name of the session to get
returns native tmux session objectTags: #tmux #session
tmux-new-window
Creates a new window in the given tmux session.
session native tmux session object
returns native tmux window objectTags: #tmux #window
tmux-new-window-named
Creates a new window in the given tmux session with a specific name.
session native tmux session object
window-name string name for the window
returns native tmux window objectTags: #tmux #window
tmux-list-windows
Lists all windows in the given tmux session.
session native tmux session object
returns block of native tmux window objectsTags: #tmux #window #list
tmux-get-pane
Gets a pane from a tmux window by index.
window native tmux window object
index integer pane index (0-based)
returns native tmux pane objectTags: #tmux #pane
tmux-split-pane
Splits a tmux pane horizontally.
pane native tmux pane object
returns native tmux pane objectTags: #tmux #pane
tmux-send-keys
Sends keys/command to a tmux pane.
pane native tmux pane object
command string command to send
returns native tmux pane objectTags: #tmux #pane #command
tmux-kill-session
Kills/destroys a tmux session.
session native tmux session object
returns native tmux session objectTags: #tmux #session
net-interface?
Looks up a network interface by name and returns it as a native object.
name String name of the network interface (e.g., "eth0", "tailscale0", "lo")
returns native net-iface object representing the interface, or error if not found
net-iface//Addrs?
Returns a block of network addresses assigned to the interface.
iface Native net-iface object
returns block of native net-addr objects assigned to the interface, or error
; iface: net-interface-by-name "lo"
; addrs: iface .Addrs?
net-addr//IPNet?
Type-asserts a network address to *net.IPNet (CIDR form). Returns failure if the address is not an IP network.
addr Native net-addr object (from net-iface//Addrs)
returns native net-ipnet object if the address is an IP network, or failure if it isa plain net.Addr (e.g., a point-to-point address not yet assigned)
; addr: iface .Addrs? |first
; ipnet: addr .IPNet?
net-ipnet//Loopback?
Reports whether the IP address in the IPNet is a loopback address.
ipnet Native net-ipnet object
returns boolean – true if the IP is a loopback address, false otherwise
; ipnet .Loopback? ; returns true for 127.0.0.1/8
net-ipnet//IPv4?
Reports whether the IP address in the IPNet is an IPv4 address (IP.To4() != nil).
ipnet Native net-ipnet object
returns boolean – true if the IP address is IPv4, false if it is IPv6-only
; ipnet .IPv4? ; returns true when the address is an IPv4 address
net-ipnet//IP-string?
Returns the IP address contained in the IPNet as a dotted-decimal (or colon-separated) string.
ipnet Native net-ipnet object
returns string representation of the IP address (without the prefix length)
; ipnet .IP-string? ; returns "100.64.0.1"
SSH
SSH server functions
ssh-server
Creates a new SSH server that listens on the specified address.
address String containing host
returns native SSH server object
server: ssh-server "localhost:2222"
server |Password-auth { pass = "secret123" }
server |Handle fn { session } {
session .Write "Welcome to Rye SSH server!
"
session .Write "Type 'exit' to quit.
"
}
server |Serve
ssh-server//Handle
Sets a handler function for SSH sessions on the server.
server SSH server object
handler Function that receives an SSH session object
returns the SSH server object
ssh-server//Password-auth
Sets a password authentication handler for the SSH server.
server SSH server object
handler Function that receives a password string and returns true/false
returns the SSH server object
ssh-server//Serve
Starts the SSH server, listening for connections.
server SSH server object
returns the SSH server object, or error if unable to serve
ssh-session//Write
Writes a string to an SSH session.
session SSH session object
text String to write to the session
returns the SSH session object
Default
go-with
Executes a function in a separate goroutine, passing the specified value as an argument.
value Object to pass to the goroutine function
function Function to execute in a separate goroutine, receives the value as argument
returns the original value that was passed to the goroutine
x:: 0 , go-with 5 fn { v } { change! v 'x } , sleep 100 , x
; returns 5
y:: 0 , go-with "test" fn { v } { change! length? v 'y } , sleep 100 , y
; returns 4
; Simple goroutine with channel communication
ch: channel 1
go fn { } { ch .Send "Hello from goroutine" }
print ch .Read
; Using waitgroup to coordinate multiple goroutines
wg: waitgroup
results: channel 10
loop 5 { i |
wg .Add 1
go-with i fn { n } { results .Send n * 2 , wg .Done }
}
wg .Wait
results .Close
; Mutex for safe shared state
counter:: 0
mtx: mutex
go fn { } { mtx .Lock , change! counter + 1 'counter , mtx .Unlock }
go
Executes a function in a separate goroutine without passing any arguments.
function Function to execute in a separate goroutine (takes no arguments)
returns the function that was executed
x:: 0 , go fn { } { change! 42 'x } , sleep 100 , x
; returns 42
y:: "unchanged" , go fn { } { change! "changed" 'y } , sleep 100 , y
; returns "changed"
channel
Creates a new channel with the specified buffer size for goroutine communication.
buffer-size Integer specifying the channel buffer size (0 for unbuffered)
returns a new channel native object with the specified buffer size
ch: channel 1 , ch .probe .lg .Send 42 , ch .Read
; returns 42
ch: channel 2 , ch .Send 1 , ch .Send 2 , ch .Read
; returns 1
channel 5 |type?
; returns native
Rye-channel//Read
Reads the next value from a channel, blocking until a value is available or the channel is closed.
channel Channel to read from
returns the next value from the channel, or an error if the channel is closed
ch: channel 1 , ch .Send 123 , ch .Read
; returns 123
ch: channel 1 , ch .Send "test" , ch .Read
; returns "test"
ch: channel 1 , ch .Close , try { ch .Read } |type?
; returns error
Rye-channel//Send
Sends a value through a channel, blocking if the channel is unbuffered or full.
channel Channel to send the value to
value Value to send through the channel
returns the channel object
ch: channel 1 , ch .Send 42 , ch .Read
; returns 42
ch: channel 3 , ch .Send "A" , ch .Send "B" , ch .Read
; returns "A"
Rye-channel//Close
Closes a channel, preventing further sends and causing pending/future reads to return an error.
channel Channel to close
returns the closed channel object
ch: channel 1 , ch .Send 42 , ch .Close , ch |type?
; returns native
ch: channel 1 , ch .Close , ch .Send 123 |disarm |type?
; returns error
ch: channel 2 , ch .Close , ch .Read |disarm |type?
; returns error
mutex
Creates a new mutex for synchronizing access to shared resources between goroutines.
(none)
returns a new mutex native object for synchronization
mutex |type?
; returns native
mtx: mutex , mtx .Lock , mtx .Unlock , mtx |type?
; returns native
waitgroup
Creates a new waitgroup for coordinating multiple goroutines to wait for completion.
(none)
returns a new waitgroup native object for coordinating goroutines
waitgroup |type?
; returns native
wg: waitgroup , wg .Add 1 , wg .Done , wg .Wait , wg |type?
; returns native
Rye-mutex//Lock
Acquires the lock on a mutex, blocking until the lock becomes available.
mutex Mutex to acquire the lock on
returns the mutex object
mtx: mutex , mtx .Lock , mtx |type?
; returns native
mtx: mutex , mtx .Lock , mtx .Unlock , mtx .Lock , mtx |type?
; returns native
Rye-mutex//Unlock
Releases the lock on a mutex, allowing other goroutines to acquire it.
mutex Mutex to release the lock from
returns the mutex object, or error if unlocking an unlocked mutex
mtx: mutex , mtx .Lock , mtx .Unlock , mtx |type?
; returns native
mtx: mutex , mtx .Unlock |disarm |type?
; returns error
Rye-waitgroup//Add
Adds the specified count to the waitgroup counter, indicating how many goroutines to wait for.
waitgroup Waitgroup to add goroutines to
count Number of goroutines to add to the wait counter
returns the waitgroup object
wg: waitgroup , wg .Add 3 , wg |type?
; returns native
wg: waitgroup , wg .Add 1 , wg .Add 2 , wg |type?
; returns native
Rye-waitgroup//Done
Decrements the waitgroup counter by one, indicating that a goroutine has completed.
waitgroup Waitgroup to decrement the counter for
returns the waitgroup object
wg: waitgroup , wg .Add 1 , wg .Done , wg |type?
; returns native
wg: waitgroup , wg .Add 2 , wg .Done , wg .Done , wg |type?
; returns native
Rye-waitgroup//Wait
Blocks until the waitgroup counter reaches zero, meaning all goroutines have completed.
waitgroup Waitgroup to wait on
returns the waitgroup object after all goroutines have completed
wg: waitgroup , wg .Add 1 , wg .Done , wg .Wait , wg |type?
; returns native
wg: waitgroup , wg .Wait , wg |type?
; returns native
select\fn
Performs a select operation on multiple channels, executing functions when channels are ready or a default function.
block Block containing channel-function pairs and optional default function
returns the original block argument
ch1: channel 1 , ch2: channel 1 , ch1 .Send 42 , select\fn { ch1 fn { v } { v } ch2 fn { v } { v + 1 } }
; returns 42
ch: channel 1 , select\fn { ch fn { v } { v * 2 } fn { } { 999 } }
; returns 999