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§
- Shell
Command - A program and its arguments, such as
login_commandreturns.
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
LocalPtyremoves them.
Functions§
- default_
shell - The user’s default shell, as Ghostty picks it with no
commandset. - login_
command - The program and arguments that start
shellwithargsas a login shell, as Ghostty does. - login_
shell - The user’s default shell as a login shell, the way a terminal starts
it:
login_commandfordefault_shellwith no arguments. - terminal_
env - The variables a terminal sets for its program, as Ghostty sets them:
TERM=xterm-ghosttywithTERMINFOpointing at the shipped database,COLORTERM=truecolor,TERM_PROGRAM=ghosttywith its version, andGHOSTTY_RESOURCES_DIRfor the shell integration scripts.