Skip to main content

Module shell

Module shell 

Source
Expand description

The user’s shell, how a terminal starts it, and the environment it gives the program, resolved as Ghostty does.

These need no pty and no feature, so an application that starts its own processes, runs its own pty, or starts a shell on a remote machine gets the same shell as the terminal’s LocalPty. terminal_env, which names Ghostty’s terminfo, needs the ghostty feature.

use gpui_cn::shell;

// The user's shell, such as /bin/zsh.
println!("{}", shell::default_shell().display());
// How a terminal starts it as a login shell, as one line.
let login = shell::login_shell();
println!("{login}");
// The same as a process to spawn.
let command: std::process::Command = login.command();

The rules come from Ghostty’s src/config/Config.zig (the default command), src/os/passwd.zig (the passwd entry) and src/termio/Exec.zig (the login shell on macOS).

Structs§

ShellCommand
A program and its arguments, such as login_command returns.

Constants§

FOREIGN_TERMINAL_ENV
Variables other terminals set that a program in this terminal must not see, since they describe that other terminal. The terminal’s LocalPty removes them.

Functions§

default_shell
The user’s default shell, as Ghostty picks it with no command set.
login_command
The program and arguments that start shell with args as a login shell, as Ghostty does.
login_shell
The user’s default shell as a login shell, the way a terminal starts it: login_command for default_shell with no arguments.
terminal_env
The variables a terminal sets for its program, as Ghostty sets them: TERM=xterm-ghostty with TERMINFO pointing at the shipped database, COLORTERM=truecolor, TERM_PROGRAM=ghostty with its version, and GHOSTTY_RESOURCES_DIR for the shell integration scripts.