Ports the parts of Ghostty's IO layer that don't depend on the terminal: - pty.zig: pty pair, window size, mode, child-side setsid/TIOCSCTTY; master is CLOEXEC with IUTF8 set - Command.zig: fork/execvpe with Ghostty's exact child setup (stdio dup2, best-effort chdir, rlimit restore, os/runtime pre-exec hooks, cgroup handling) and exit status decoding - shell_integration.zig for bash/zsh/fish/elvish/nushell plus feature flags; scripts copied verbatim to resources/shell-integration/ - terminfo generator for xterm-ghostty, byte-identical to Zig's encode output (golden file produced with the real Zig code) This crate opts into unsafe_code = "deny" (fork/exec need it) with allow + SAFETY comments on minimal items. Integration left: config-derived option types are local stand-ins; cgroup D-Bus scope creation is a closure hook; Exec/Termio/Thread/ stream_handler wait for ghostty-terminal. Pty now closes both fds on drop (Zig never auto-closed the slave) - to re-check when wiring Exec. Test Plan: - cargo test -p ghostty-termio (52 tests, incl. real pty spawn test expecting "hi\r\n31 97\r\n" from `echo hi; stty size`)
62 lines
2.7 KiB
Bash
62 lines
2.7 KiB
Bash
# Based on (started as) a copy of Kitty's zsh integration. Kitty is
|
|
# distributed under GPLv3, so this file is also distributed under GPLv3.
|
|
# The license header is reproduced below:
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# This script is sourced automatically by zsh when ZDOTDIR is set to this
|
|
# directory. It therefore assumes it's running within our shell integration
|
|
# environment and should not be sourced manually (unlike ghostty-integration).
|
|
#
|
|
# This file can get sourced with aliases enabled. To avoid alias expansion
|
|
# we quote everything that can be quoted. Some aliases will still break us
|
|
# though.
|
|
|
|
# Restore the original ZDOTDIR value if GHOSTTY_ZSH_ZDOTDIR is set.
|
|
# Otherwise, unset the ZDOTDIR that was set during shell injection.
|
|
if [[ -n "${GHOSTTY_ZSH_ZDOTDIR+X}" ]]; then
|
|
'builtin' 'export' ZDOTDIR="$GHOSTTY_ZSH_ZDOTDIR"
|
|
'builtin' 'unset' 'GHOSTTY_ZSH_ZDOTDIR'
|
|
else
|
|
'builtin' 'unset' 'ZDOTDIR'
|
|
fi
|
|
|
|
# Use try-always to have the right error code.
|
|
{
|
|
# Zsh treats unset ZDOTDIR as if it was HOME. We do the same.
|
|
#
|
|
# Source the user's .zshenv before sourcing ghostty-integration because the
|
|
# former might set fpath and other things without which ghostty-integration
|
|
# won't work.
|
|
#
|
|
# Use typeset in case we are in a function with warn_create_global in
|
|
# effect. Unlikely but better safe than sorry.
|
|
'builtin' 'typeset' _ghostty_file=${ZDOTDIR-$HOME}"/.zshenv"
|
|
# Zsh ignores unreadable rc files. We do the same.
|
|
# Zsh ignores rc files that are directories, and so does source.
|
|
[[ ! -r "$_ghostty_file" ]] || 'builtin' 'source' '--' "$_ghostty_file"
|
|
} always {
|
|
if [[ -o 'interactive' ]]; then
|
|
# ${(%):-%x} is the path to the current file.
|
|
# On top of it we add :A:h to get the directory.
|
|
'builtin' 'typeset' _ghostty_file="${${(%):-%x}:A:h}"/ghostty-integration
|
|
if [[ -r "$_ghostty_file" ]]; then
|
|
'builtin' 'autoload' '-Uz' '--' "$_ghostty_file"
|
|
"${_ghostty_file:t}"
|
|
'builtin' 'unfunction' '--' "${_ghostty_file:t}"
|
|
fi
|
|
fi
|
|
'builtin' 'unset' '_ghostty_file'
|
|
}
|