TheFile.Ninja

Manual · fn 0.1.6

fn: skalets länk till panelerna

Det som är markerat i panelerna i dina kommandon, dina kommandons utdata i panelerna, och filoperationer från skalet som Ctrl+Z tar tillbaka.

Manualen är på engelska.

What it is

fn is a small program that TheFile.Ninja hands to everything it starts: the terminal under a list, the commands a Lua script runs, a program on the toolbar, a .ps1 or .bat opened with Enter. Through it the shell sees what the panes show — the folder, the marked items, every place the app can list — and the panes show what the shell makes.

It is there only inside the app. It is not put on the computer’s PATH: a command that fails whenever the app is not running would be worse than none. Standard output is data, standard error is talk, and the exit code is the outcome, so fn fits in a pipeline, in $(…) and in for /f.

A first look

Open a terminal under the list (Ctrl+O, by default) and try:

fn sel                               # the marked items, else the one under the cursor: one path a line
fn cp --sel                          # copy them into the other pane's folder, as F5 does
fn rm *.tmp                          # to the Recycle Bin; fn undo, or Ctrl+Z, puts them back
rg -l TODO | fn mount todos --open   # the files a search found, as a folder in the pane
cd "$(fn pick --folder)"             # the pane as the shell's folder dialog

fn help lists the commands, and fn help cp says everything about one. This page is those texts, for fn 0.1.6.

Which pane

A terminal sits under a tab, and fn run in it means that tab: its folder, its marks. Not whichever pane happens to be active. --pane reaches the others: here (this terminal's tab), active, other, left, right. Where there is no terminal (a program started from the toolbar), “here” is the active pane.

Items

The commands that act on files take their items in three ways:

  • Named, wildcards too: fn rm *.tmp. fn expands the wildcards itself, so PowerShell and cmd, which pass *.tmp on as it is, work as bash does. Hidden and system files are left out.
  • Piped in, with -: fn sel | fn rm - (-0 for names ending in a NUL character).
  • The pane’s own, with --sel: the marked items, else the one under the cursor.

Never none. A command that changes files and names no items is refused, so nothing ever acts on whatever happens to be marked because the items were left out. The items may be anywhere the app reaches: on a server, inside an archive, on a phone.

Undo

fn cp, fn mv, fn rm, fn ren, fn mkdir, fn tag, fn untag and fn desc --set do not touch the files themselves. They start an operation of the app, the same one a key would: its progress shows in the strip under the panes and as one line in the terminal, a name that is already taken is asked about in the app (or answered in advance with --overwrite, --skip, --keep-both, --older), and it is in the operation history for 30 days.

So fn rm deletes to the Recycle Bin, a file that is replaced is kept aside, and fn undo or Ctrl+Z takes the whole thing back. That is the reason to write fn rm in a script where you would have written rm. The one exception says so in its name: fn rm --for-good.

Paths and shells

Paths come and go in the shell’s own form: C:\Users\me in PowerShell and cmd, /mnt/c/Users/me and /home/me in WSL, /c/Users/me in Git Bash. --win prints Windows’ form everywhere. Lists are one item a line, -0 ends each with a NUL character instead, and --json gives one object a line.

  • PowerShell pipes objects, not text. Get-ChildItem *.pdf | fn mount pdfs mounts the files, Select-String’s matches arrive as places in files, and Get-Service | fn mount services shows each service’s display properties. fn cd changes the location.
  • bash, in WSL and Git Bash: fn is a function there, so fn cd works and WSL finds the Windows program.
  • cmd has no functions: fn cd asks the app, which types the cd at the terminal’s next prompt.

None of this touches your own shell settings: the terminal sets it up for the shells it starts.

What the panes show

Reading: nothing here changes a file. Places need not be folders on a disk: an archive, a server, a phone, a tag or a search lists the same way.

fn pwd [PANE] [options]

The folder a pane shows

--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
--any
Also a place that is no folder on a disk (a server, an archive, a search): its address
--win
Paths as Windows writes them, also in WSL and Git Bash
fn pwd
fn pwd other
cp report.pdf "$(fn pwd other)"

fn sel [options]

A pane's items: the marked ones, else the one under the cursor

--marked
Only the marked items
--cursor
Only the item under the cursor
--shown
Every item the pane shows (its filter applied)
--all
Every item of the folder, hidden ones too
--any
Also items that are not on a disk (on a server, in an archive): their addresses
-0, --null
Each item ends with a NUL character instead of a line break
--json
One JSON object per line
--win
Paths as Windows writes them, also in WSL and Git Bash
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn sel
fn sel --pane other
fn sel -0 | xargs -0 du -h
fn sel | ForEach-Object { magick $_ ($_ -replace '\.\w+$', '.webp') }

fn ls [PLACE] [options]

What a place holds, any place the app lists: a folder, an archive (a.zip|in), a server, a phone, tag://, coll://, Recent; none: the pane's folder

--all
Hidden and system items too
--dirs
Only folders
--files
Only files
-0, --null
Each item ends with a NUL character instead of a line break
--json
One JSON object per line
--win
Paths as Windows writes them, also in WSL and Git Bash
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn ls
fn ls 'D:\photos.zip|2024'
fn ls sftp://me@nas/var/www --json
fn ls tag://WORK

fn find QUERY… [options]

The app's search (Everything's syntax; Everything where it indexes, its own walk elsewhere): here and below

--in FOLDER
Search there (else here: the shell's folder and below)
--everywhere
Search everywhere, not only here
--max N
At most N results
-0, --null
Each item ends with a NUL character instead of a line break
--json
One JSON object per line
--win
Paths as Windows writes them, also in WSL and Git Bash
fn find ext:pdf dm:thisweek
fn find *.psd "size:>100mb" --everywhere --max 50
fn find content:TODO ext:rs

fn ai TEXT… [options]

A search said in words, written by the AI provider chosen in Preferences, then run

--query
Only print the search the AI wrote
--max N
At most N results
-0, --null
Each item ends with a NUL character instead of a line break
--json
One JSON object per line
--win
Paths as Windows writes them, also in WSL and Git Bash
fn ai stora pdf:er från förra månaden
fn ai photos from last summer --query

fn get ITEMS… [options]

A file on this computer for each item: itself on a disk, else a copy (archives, servers, phones); prints the paths

--win
Paths as Windows writes them, also in WSL and Git Bash
fn get sftp://me@nas/video.mkv
ffprobe (fn get 'D:\a.zip|clip.mp4')

fn cat ITEMS…

A file's bytes on standard output, wherever it is (archives, servers, phones)

fn cat 'D:\a.zip|readme.md'
fn cat sftp://me@nas/etc/hosts

fn tags [ITEMS…] [options]

Each item's tags

--sel
The pane's marked items, else the one under the cursor
--json
One JSON object per line
-0, --null
Items piped in (-) end with a NUL character instead of a line break
--win
Paths as Windows writes them, also in WSL and Git Bash
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn tags --sel
fn tags *.pdf --json

Going there, and picking

The pane follows the shell, the shell follows the pane, and the pane stands in for a file dialog.

fn go [PATH] [options]

Shows a folder in a pane (a file: in its folder, the cursor on it); no PATH: the shell's own folder

--tab
In a new tab
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn go
fn go ..
fn go src/main.rs
fn go 'C:\Users\me\Pictures' --pane other
fn go sftp://me@nas/var/www --tab

fn cd [PANE] [options]

The shell goes to the folder a pane shows

--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn cd
fn cd other

fn pick [options]

Waits while you pick in a pane, as in a file dialog, and prints what was picked

--file
Only a file
--folder
Only a folder
--multi
Several items: the marked ones
--in FOLDER
Start there (the pane goes there first)
--prompt TEXT
What the bar above the list says it is for
--any
Also items that are not on a disk (on a server, in an archive): their addresses
-0, --null
Each item ends with a NUL character instead of a line break
--json
One JSON object per line
--win
Paths as Windows writes them, also in WSL and Git Bash
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
code (fn pick)
cd "$(fn pick --folder)"
fn pick --multi -0 | xargs -0 du -h
fn pick --file --in C:\logs

Changing files

Each is an operation of the app: its progress shows under the panes, a name that is taken is asked about there, and Ctrl+Z or fn undo takes it back.

fn cp [ITEMS…] [options]

Copies items through the app (anywhere it reaches: servers, archives, phones); Ctrl+Z undoes it

--to FOLDER
Where to (else the other pane's folder)
--sel
The pane's marked items, else the one under the cursor
--overwrite
Replace what is there (it is kept aside: undo puts it back)
--skip
Leave out what is there already
--keep-both
Keep both: the new one gets a free name, “name (2)”
--older
Replace what is there only when it is older
--no-wait
Do not wait for the operation: its number is printed
-0, --null
Items piped in (-) end with a NUL character instead of a line break
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn cp --sel
fn cp *.pdf --to D:\Backup
fn sel --pane other | fn cp - --skip

fn mv [ITEMS…] [options]

Moves items through the app; Ctrl+Z undoes it

--to FOLDER
Where to (else the other pane's folder)
--sel
The pane's marked items, else the one under the cursor
--overwrite
Replace what is there (it is kept aside: undo puts it back)
--skip
Leave out what is there already
--keep-both
Keep both: the new one gets a free name, “name (2)”
--older
Replace what is there only when it is older
--no-wait
Do not wait for the operation: its number is printed
-0, --null
Items piped in (-) end with a NUL character instead of a line break
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn mv --sel
fn mv *.jpg --to ..\Pictures
rg -l --null TODO | fn mv - -0 --to todo

fn rm [ITEMS…] [options]

Deletes items to the Recycle Bin (where a disk has none, aside); Ctrl+Z puts them back

--sel
The pane's marked items, else the one under the cursor
--for-good
Delete for good, not to the Recycle Bin (cannot be undone)
--no-wait
Do not wait for the operation: its number is printed
-0, --null
Items piped in (-) end with a NUL character instead of a line break
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn rm *.tmp
fn rm --sel
fn sel | fn rm -

fn ren ITEM NAME [options]

Gives an item a new name (in its folder); Ctrl+Z undoes it

--no-wait
Do not wait for the operation: its number is printed
fn ren draft.txt final.txt

fn mkdir FOLDERS… [options]

Makes folders through the app; Ctrl+Z removes them

--no-wait
Do not wait for the operation: its number is printed
fn mkdir photos
fn mkdir a b c

fn tag TAGS [ITEMS…] [options]

Tags items (TAGS: WORK or WORK,URGENT); Ctrl+Z takes those tags off again

--sel
The pane's marked items, else the one under the cursor
--no-wait
Do not wait for the operation: its number is printed
-0, --null
Items piped in (-) end with a NUL character instead of a line break
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn tag WORK report.pdf
fn tag WORK,URGENT --sel
rg -l TODO | fn tag TODO -

fn untag TAGS [ITEMS…] [options]

Takes tags off items; Ctrl+Z puts them back

--sel
The pane's marked items, else the one under the cursor
--no-wait
Do not wait for the operation: its number is printed
-0, --null
Items piped in (-) end with a NUL character instead of a line break
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn untag URGENT --sel

fn desc [ITEMS…] [options]

Each item's description (the one the app shows), or with --set or --clear a new one

--set TEXT
Give them this description (one line); Ctrl+Z puts back what they had
--clear
Take their descriptions off; Ctrl+Z puts them back
--sel
The pane's marked items, else the one under the cursor
--json
One JSON object per line
--no-wait
Do not wait for the operation: its number is printed
-0, --null
Items piped in (-) end with a NUL character instead of a line break
--win
Paths as Windows writes them, also in WSL and Git Bash
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
fn desc report.pdf
fn desc *.pdf --set "Signed copy"
fn desc --sel --clear
fn find ext:pdf dm:today | fn desc - --set Inbox

fn undo [options]

Undoes the newest file operation (as Ctrl+Z does)

--no-wait
Do not wait for the operation: its number is printed
fn undo

fn redo [options]

Does the operation undone last again

--no-wait
Do not wait for the operation: its number is printed
fn redo

fn jobs [options]

The file operations running now and the newest ones done

--json
One JSON object per line
fn jobs

fn wait [IDS…]

Waits for operations (their numbers; none: all that run)

fn wait
fn wait 42

A command’s output as a folder

Whatever a command prints becomes rows in a pane; rows that name files are those files, to preview, open, copy and drag.

fn mount ID [options]

A command's output as a folder, lua://ID/: files it names are those files, other fields show beside them

--json
The input is JSON: one object per line, or an array
--tsv
The input is tab-separated, its first line the field names
--csv
The input is comma-separated, its first line the field names
--lines
Each line is a row (else the kind of input is recognised)
-0, --null
Records end with a NUL character (names may hold line breaks)
--fields A,B
The field names, when the first line is no header
--name-field FIELD
Which field names a row (else name, else the item's name, else the first)
--add
Add to the folder's rows instead of replacing them
--open
Show the folder in the pane
--paths
Rows naming files and folders are those items (the default: recognised)
--no-paths
Rows are only text, even when they name a file
--pane PANE
Which pane: here (this terminal's tab, the default), active, other, left, right
rg -l TODO | fn mount todos --open
cargo build 2>&1 | fn mount errors --open
git status --porcelain | fn mount changed --open
Get-ChildItem -Recurse -Filter *.pdf | fn mount pdfs --open
docker ps --format '{{.Names}}\t{{.Image}}\t{{.Status}}' | fn mount docker --tsv --fields name,image,status

fn unmount ID

Empties the script folder lua://ID/

fn unmount todos

fn mounts [options]

The script folders and how many rows each holds

--json
One JSON object per line
fn mounts

fn itself

fn ping

Whether the app answers, and which pane and tab this terminal belongs to

fn ping

fn help [COMMAND]

What fn does, or one command in full

fn help
fn help mount

fn version

fn's version

fn version

Exit codes

0
done
1
error
2
usage
3
the app is not running
4
timed out
5
not authorised
6
cancelled
7
nothing

“Nothing” (7) is what grep answers when it finds nothing: no rows, no folder. fn pwd && … goes on only where the pane shows a real folder.

Editions

fn is in the free Core edition, where the terminal runs cmd. Three things around it are part of Pro: the other shells in the terminal (PowerShell, Git Bash, WSL), fn mount (script folders), and fn ai (the AI features).

The terminal’s own assistant writes fn commands where they fit, and checks each against fn’s grammar before it shows it. An AI assistant started in the terminal has fn too; one started elsewhere reaches the app through its MCP server.

▶ Terminalen och fn · 2 min