Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion capture.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
zmodload zsh/zpty || { echo 'error: missing module zsh/zpty' >&2; exit 1 }

# spawn shell
zpty z zsh -f -i
zpty z zsh -i

# line buffer for pty output
local line

# swallow input of zshrc, disable hooks and disable PROMPT
# the prompt is disabled later as well but at least with powerlevel10k
# it needs to be disabled twice.
zpty -w z "autoload add-zsh-hook"
zpty -w z "add-zsh-hook -D precmd '*'"
zpty -w z "add-zsh-hook -D preexec '*'"
zpty -w z "PROMPT="
zpty -w z "echo thisisalonganduniquestringtomarktheendoftheinit >/dev/null"
zpty -r z line
while [[ $line != *'thisisalonganduniquestringtomarktheendoftheinit'* ]]; do
zpty -r z line
done

setopt rcquotes
() {
zpty -w z source $1
Expand Down