From 8a2767515f8a0e558fafb2c342f941f34f247f5d Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 12 Feb 2024 07:10:20 +0000 Subject: [PATCH] Split transient.zsh back out to fix shell exit issues --- home/zsh/default.nix | 33 +-------------------------------- home/zsh/transient.zsh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 32 deletions(-) create mode 100755 home/zsh/transient.zsh diff --git a/home/zsh/default.nix b/home/zsh/default.nix index ed212e58..53b26dd3 100644 --- a/home/zsh/default.nix +++ b/home/zsh/default.nix @@ -24,37 +24,6 @@ zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' zstyle ':completion:*' menu select ''; - initExtra = '' - ## enable transient prompt - zle-line-init() { - emulate -L zsh - - [[ $CONTEXT == start ]] || return 0 - - while true; do - zle .recursive-edit - local -i ret=$? - [[ $ret == 0 && $KEYS == $"\4" ]] || break - [[ -o ignore_eof ]] || exit 0 - done - - local saved_prompt=$PROMPT - local saved_rprompt=$RPROMPT - PROMPT="> " - RPROMPT="" - zle .reset-prompt - PROMPT=$saved_prompt - RPROMPT=$saved_rprompt - - if ((ret)); then - zle .send-break - else - zle .accept-line - fi - return ret - } - - zle -N zle-line-init - ''; + initExtra = "source ${./transient.zsh}\n"; }; } diff --git a/home/zsh/transient.zsh b/home/zsh/transient.zsh new file mode 100755 index 00000000..d01b945e --- /dev/null +++ b/home/zsh/transient.zsh @@ -0,0 +1,31 @@ +#!/usr/bin/env zsh + +zle-line-init() { + emulate -L zsh + + [[ $CONTEXT == start ]] || return 0 + + while true; do + zle .recursive-edit + local -i ret=$? + [[ $ret == 0 && $KEYS == $'\4' ]] || break + [[ -o ignore_eof ]] || exit 0 + done + + local saved_prompt=$PROMPT + local saved_rprompt=$RPROMPT + PROMPT='> ' + RPROMPT='' + zle .reset-prompt + PROMPT=$saved_prompt + RPROMPT=$saved_rprompt + + if ((ret)); then + zle .send-break + else + zle .accept-line + fi + return ret +} + +zle -N zle-line-init