Zsh functions: set options for better error handling
This commit is contained in:
parent
cf620b0642
commit
83ff053395
|
@ -4,6 +4,8 @@
|
|||
# https://tintin.mudhalla.net/info/256color/
|
||||
# https://gist.github.com/Prakasaka/219fe5695beeb4d6311583e79933a009
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
function _ansi-colors_8()
|
||||
{
|
||||
local title="${1}"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Compare 2 Btrfs snapshots
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
if [[ ${ARGC} -lt 2 ]]; then
|
||||
print -u 2 "Usage: ${0} <old> <new>"
|
||||
return 1
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
# export CATOPEN="highlight --force --out-format=truecolor --stdout %s"
|
||||
# alias cat='cat-highlight'
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
# Check if we are in a terminal and a highlighter is defined
|
||||
if [[ -t 1 ]] && [[ -n "${CATOPEN}" || -n "${LESSOPEN}" ]]; then
|
||||
if [[ -z "${CATOPEN}" ]]; then
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# number. Will return instead of exit when the shell is interactive.
|
||||
# Put this in ${fpath} and load it with `autoload -U die`.
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
local errorcode=${?}
|
||||
if [[ -v 1 && ${1} =~ '^[0-9]+$' ]]; then
|
||||
errorcode=${1}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Export variable to Emacs.
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
if [[ ARGC -eq 0 ]]; then
|
||||
print -u 2 "Usage: ${0} <variable> …"
|
||||
return 1
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Get backtrace from gdb
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
if [[ ${ARGC} -ne 2 ]]; then
|
||||
print -u 2 "Usage: ${0} <executable> <core dump>"
|
||||
return 1
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
# Makes all files in <directory> lower case. Works with Non-ASCII characters.
|
||||
# Equivalent to `zmv "${dir}/(*)" '${dir}/${1:l}'`
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
if [[ ${ARGC} -ne 1 ]]; then
|
||||
print -u 2 "Usage: ${0} <directory>"
|
||||
return 1
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Put files on a webspace via sftp
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
if [[ ${ARGC} -eq 0 ]]; then
|
||||
print -u 2 "Usage: ${0} <file> …"
|
||||
return 1
|
||||
|
|
Loading…
Reference in New Issue