← XeFM English | 日本語 · crftwr/xefm on GitHub · craftware

Terminal

English | 日本語

Some things XeFM runs need a terminal: the subshell (subshell, Tools → Subshell Here) and programs that draw a screen or read the keyboard, such as vim, less or a REPL. How XeFM gives them one depends on how it runs:

Which commands get a terminal

TEXT_EDITOR, TEXT_DIFF, the open, view and edit commands in FILE_ASSOCIATIONS, and PROGRAMS entries can all be marked the same way:

TEXT_EDITOR = {'command': 'vim', 'terminal': True}
TEXT_DIFF = {'command': ['code', '--diff', '--wait'], 'terminal': False}
{'pattern': '*.log', 'view': {'command': ['less'], 'terminal': True}},
{'name': 'Python REPL', 'command': ['python3'], 'terminal': True},
Marking In a terminal In the desktop app
'terminal': True gets the terminal; XeFM waits runs in a terminal session
'terminal': False runs in the background, output in the log pane the same
unmarked (a plain string or list) gets the terminal; XeFM waits runs in the background, output in the log pane

A PROGRAMS entry without a marking runs in the background in both modes, as it always has. See External Programs and File Associations for the rest of those settings.

A program in the background is never waited for. If it exits with an error, the log pane says so. A program that keeps running after XeFM quits, such as an editor, is not stopped by XeFM quitting.

In the desktop app: terminal sessions and screens

Subshell Here starts your shell in the active pane’s directory, in XeFM’s terminal over the panes. A program marked 'terminal': True opens the same way. Each is a terminal session, shown on a screen of its own.

A screen is what fills the window: the file manager’s (the panes) or a session’s. A screen keeps what is open on it. A viewer you opened over the panes is still there when you come back from a terminal, so you can look at a file and a terminal by turns, switching between the two screens.

The keys are on Keymap Presets.

XeFM’s terminal runs on libghostty, which the macOS and Windows apps include. XeFM installed with pip has no libghostty, so its desktop app has no terminal: the subshell and terminal programs do not start there, and the log says why. Run XeFM in a terminal (--backend vt) for them instead.

Selecting, copying and pasting

Drag to select text; double-click selects a word, triple-click a line, and Alt+drag a rectangle. In a program that uses the mouse itself (vim, htop), hold Shift while you drag.

  Every system macOS Also on Windows
Copy the selection Ctrl+Shift+C, Ctrl+Insert Cmd+C Ctrl+C
Paste Ctrl+Shift+V, Shift+Insert Cmd+V Ctrl+V

A copy key with nothing selected goes to the program, so Ctrl+C still interrupts it. On Windows, Ctrl+C copies a selection and then clears it, so pressing it again interrupts. If a program needs Ctrl+C and Ctrl+V itself (vim’s block selection, Emacs), set TERMINAL_CTRL_CLIPBOARD = False in config.py: both keys then go to the program, and the other keys still copy and paste.

A right-click copies the selection and clears it, or pastes when nothing is selected, as in Windows Terminal. A program that uses the mouse gets the right-click instead; hold Shift to copy or paste.

A pasted line break is sent as Enter, so pasting several lines runs them one after another.

The shell’s environment

A shell XeFM starts gets the XEFM_* variables with the pane directories and selections, XEFM_ACTIVE, and the [XeFM] prompt marker (see User Guide: Subshell). Those variables hold the panes as they were when the shell started; a session you keep for a while should ask xefmctl instead.

For zsh and for bash 4.4 or later (macOS’s own bash is 3.2), XeFM adds a few lines of shell integration when it starts them, so it can tell when the shell waits at its prompt and when a command ends. Your own startup files still run as usual.

News from a hidden session

While a session is hidden, the status bar shows what needs your attention: a command that ran for 10 seconds or more has finished or failed, a program failed, or a program sent a notification (OSC 9 or OSC 777), as Claude Code and other tools can. A program that reports its progress (OSC 9;4) shows it there too. Click it to bring the session back.

Shell integration also tells the switcher the command line running in a session. Without it, macOS and Linux still show the name of the program running there; on Windows, the title the program sets.

In a terminal

XeFM in a terminal does not draw a second terminal inside itself. The subshell and terminal programs get the terminal XeFM runs in, and you return to XeFM when they exit. There are no terminal sessions and no screens to switch between, so Screens is not in the menu or the command palette.

This is the one difference between the two: the desktop app can keep a shell running behind the panes, and XeFM in a terminal cannot. To work in parallel there, use the tabs or windows of your terminal, or tmux. To open another terminal window from XeFM, add a PROGRAMS entry for it; the config template has examples for Terminal.app, iTerm, Windows Terminal and tmux.

Asking XeFM from the shell

In a shell XeFM started (the subshell, a terminal session, a PROGRAMS entry), the xefmctl command asks that XeFM for its state at the moment it runs, and acts on its file manager:

xefmctl state                                  # what XeFM shows now
cp $(xefmctl pane selected) /tmp               # names without spaces
xefmctl pane cd .                              # bring the active pane here
xefmctl view build.log                         # Screens takes you back to compare
xefmctl screen show files

It also searches anywhere XeFM can go, shows lists in a pane, copies through XeFM and asks you questions: see xefmctl for every command. An AI agent that XeFM opens uses it to work beside you.

The TERMINAL setting

Earlier versions read TERMINAL in config.py to choose a terminal application for the desktop app. XeFM’s own terminal runs those things now, and TERMINAL is no longer used: XeFM says so once when it loads a config that still sets it. To open your terminal application from XeFM, add a PROGRAMS entry for it.

See also