Types
Shared
Cha
Cha means one file's characteristics with the following properties:
is_dir
- Whether this file is a directoryis_hidden
- Whether this file is hidden (starts with a dot)is_link
- Whether this file is a symlinkis_orphan
- Whether this file is a bad symlink, which points to a non-existent fileis_dummy
- Whether the file is dummy, which fails to load complete metadata, possibly the filesystem doesn't support it, such as FUSE.is_block
- Whether this file is a block deviceis_char
- Whether this file is a character deviceis_fifo
- Whether this file is a fifois_sock
- Whether this file is a socketis_exec
- Whether this file is executableis_sticky
- Whether this file has the sticky bit setlength
- The length of this file, returns an integer representing the size in bytes. Note that it can't reflect the size of a directory, usesize()
insteadcreated
- The created time of this file in Unix timestamp, ornil
if it doesn't have a valid timemodified
- The modified time of this file in Unix timestamp, ornil
if it doesn't have a valid timeaccessed
- The accessed time of this file in Unix timestamp, ornil
if it doesn't have a valid timepermissions
- Unix permissions of this file in string, e.g.drwxr-xr-x
. For Windows, it's alwaysnil
And the Unix only properties:
uid
- The user id of this filegid
- The group id of this filenlink
- The number of hard links to this file
File
Properties:
url
- The Url of this filecha
- The Cha of this filelink_to
- The Url of this file pointing to, if it's a symlink; otherwise,nil
name
- The name of this file
Icon
Properties:
text
- The text of this iconstyle
- The Style of this icon
Range
TODO
Url
Create a Url:
-- regular file
local url = Url("/root/Downloads/logo.png")
-- `bgm.mp3` from the archive `ost.zip`
local url = Url("archive:///root/ost.zip#bgm.mp3")
Properties:
frag
- The fragment string of the url. Let's say the urlarchive:///root/my-archive.zip#1.jpg
, the fragment1.jpg
is_regular
- Whether the file represented by the url is a regular fileis_search
- Whether the file represented by the url from the search resultis_archive
- Whether the file represented by the url from an archiveis_absolute
- Whether the path represented by the url is absolutehas_root
- Whether the path represented by the url has a root
Methods:
name()
- Returns the filename in string if any, otherwisenil
stem()
- Returns the filename without the extension in string if any, otherwisenil
join(url)
- Joins with anotherUrl
or a string of url, returns a newUrl
parent()
- Returns parent directoryUrl
if any, otherwisenil
starts_with(url)
- Whether the url starts with anotherUrl
or a string of urlends_with(url)
- Whether the url ends with anotherUrl
or a string of urlstrip_prefix(url)
- Strips the prefix of anotherUrl
or a string of url, returns a newUrl
Meta methods:
__eq(another_url)
__tostring()
__concat(string)
Window
Properties:
rows
- The number of rows of this windowcols
- The number of columns of this windowwidth
- The width of this window in pixelsheight
- The height of this window in pixels
App data
You can access all app data through the cx
within Sync context:
cx.active
- The active tab, which is a tab::Tabcx.tabs
- All of tabs, which is a manager::Tabscx.tasks
- All of tasks, which is a tasks::Taskscx.yanked
- The yanked urls, which is a manager::Yanked
tab::Mode
Visual mode status.
Properties:
is_select
- Whether the mode is selectis_unset
- Whether the mode is unsetis_visual
- Whether the mode is select or unset
Meta methods:
__tostring()
tab::Config
Properties:
sort_by
sort_sensitive
sort_reverse
sort_dir_first
sort_translit
linemode
show_hidden
These properties are consistent with those in yazi.toml, and will not be detailed here.
tab::Selected
Meta methods:
__len()
__pairs()
- Iterate over the selected Urls.
tab::Preview
Properties:
skip
- The number of units to skip. The units largely depend on your previewer, such as lines for code and percentages for videos.folder
- The folder::Folder being previewed, ornil
if this preview is not for folders
folder::Folder
Properties:
cwd
- The current working directory of this folder, which is a Urloffset
- The offset of this folder, which is an integercursor
- The cursor position of this folder, which is an integerwindow
- A table of File in the visible area of this folderfiles
- Thefolder::Files
of this folderhovered
- The hovered File of this folder, ornil
if there is no hovered file
folder::Files
Meta methods:
__len()
__index(idx)
- Access the folder::File by index
folder::File
Based on File, with the following additional methods:
size()
- The size of this file, returns an integer representing the size in bytes, ornil
if its a directory and it has not been evaluatedmime()
- The mime-type of this file, which is a string, ornil
if it's a directory or hasn't been lazily calculated at allprefix()
- The prefix of this file relative toCWD
, which used in the flat view during search. For instance, ifCWD
is/foo
, and the file is/foo/bar/baz
, then the prefix isbar/
icon()
- The Icon of this file,[icon]
rules are applied; if no rule matches, returnsnil
style()
- The Style of this file,[filetype]
rules are applied; if no rule matches, returnsnil
is_hovered()
- Whether this file is hoveredis_yanked()
- Whether this file is yankedis_selected()
- Whether this file is selectedfound()
- When users find a file using thefind
command, the status of the file - returnsnil
if it doesn't match the user's find keyword; otherwise, returns{idx, all}
, whereidx
is the position of matched file, andall
represents the number of all matched files.highlights()
- TODO
manager::Tabs
Properties:
idx
- The index of the active tab
Meta methods:
__len()
__index(idx)
tab::Tab
Properties:
mode
- The tab::Mode of this tab.conf
- The tab::Config of this tab.current
- The current folder within this tab, which is a folder::Folder.parent
- The parent folder within this tab, which is a folder::Folder ifcurrent
has a parent; otherwise,nil
.selected
- The selected files within this tab, which is a tab::Selected.preview
- The tab::Preview within this tab.
Methods:
name()
- The name of this tab
tasks::Tasks
Properties:
-
progress
- The progress of all tasks, which is a table:{
-- Number of tasks
total = 0,
succ = 0,
fail = 0,
-- Workload of tasks
found = 0,
processed = 0,
}
manager::Yanked
for idx, url in pairs(cx.yanked) do
-- ...
end
Meta methods:
__len()
__pairs()
- Iterate over the yanked Urls.
Properties:
is_cut
- Whether the yanked urls are cut.