Zsh: Add function: die()
This commit is contained in:
parent
64c12cd4cf
commit
5e925e84a8
18
.config/zsh/functions/die
Executable file
18
.config/zsh/functions/die
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/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`.
|
||||||
|
|
||||||
|
local errorcode=${?}
|
||||||
|
if [[ -v 1 && ${1} =~ '^[0-9]+$' ]]; then
|
||||||
|
errorcode=${1}
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -v 1 ]]; then
|
||||||
|
print -Pnu2 "%B%F{201}"
|
||||||
|
print -u2 "${@}"
|
||||||
|
print -Pnu2 "%f%b"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit ${errorcode}
|
Loading…
Reference in New Issue
Block a user