From cf620b0642a8a515ae229bb57cf2c15b63965632 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 3 Apr 2022 05:08:51 +0200 Subject: [PATCH] Zsh: die(): return instead of exit if interactive --- .config/zsh/functions/die | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/zsh/functions/die b/.config/zsh/functions/die index 9c1711d..1702315 100755 --- a/.config/zsh/functions/die +++ b/.config/zsh/functions/die @@ -1,7 +1,8 @@ #!/usr/bin/env zsh # Exit with the error code of the last command and an optional error message in # bold pink. The error code is overridden by the first argument, if it is a -# number. Put this in ${fpath} and load it with `autoload -U die`. +# number. Will return instead of exit when the shell is interactive. +# Put this in ${fpath} and load it with `autoload -U die`. local errorcode=${?} if [[ -v 1 && ${1} =~ '^[0-9]+$' ]]; then @@ -15,4 +16,5 @@ if [[ -v 1 ]]; then print -Pnu2 "%f%b" fi +[[ -o INTERACTIVE ]] && return ${errorcode} exit ${errorcode}