Use zsh style tests for empty vars
This commit is contained in:
parent
4ad8f8db8e
commit
393bd00114
4 changed files with 22 additions and 22 deletions
|
@ -39,7 +39,7 @@ unsetopt HUP
|
|||
unsetopt CHECK_JOBS
|
||||
|
||||
# Set less or more as the default pager.
|
||||
if [[ -z ${PAGER} ]]; then
|
||||
if (( ${+PAGER} )); then
|
||||
if (( ${+commands[less]} )); then
|
||||
export PAGER=less
|
||||
else
|
||||
|
|
|
@ -41,20 +41,20 @@ case $1 in
|
|||
fi
|
||||
|
||||
# set default options
|
||||
[ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd"
|
||||
[ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help"
|
||||
[ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox"
|
||||
[ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo"
|
||||
[ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null
|
||||
[ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1
|
||||
[ -z "$_FASD_MAX" ] && _FASD_MAX=2000
|
||||
[ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native
|
||||
[ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2
|
||||
[ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo"
|
||||
[ -z "$_FASD_RECENTLY_USED_XBEL" ] && \
|
||||
(( "${+_FASD_DATA}" )) && _FASD_DATA="$HOME/.fasd"
|
||||
(( "${+_FASD_BLACKLIST}" )) && _FASD_BLACKLIST="--help"
|
||||
(( "${+_FASD_SHIFT}" )) && _FASD_SHIFT="sudo busybox"
|
||||
(( "${+_FASD_IGNORE}" )) && _FASD_IGNORE="fasd ls echo"
|
||||
(( "${+_FASD_SINK}" )) && _FASD_SINK=/dev/null
|
||||
(( "${+_FASD_TRACK_PWD}" )) && _FASD_TRACK_PWD=1
|
||||
(( "${+_FASD_MAX}" )) && _FASD_MAX=2000
|
||||
(( "${+_FASD_BACKENDS}" )) && _FASD_BACKENDS=native
|
||||
(( "${+_FASD_FUZZY}" )) && _FASD_FUZZY=2
|
||||
(( "${+_FASD_VIMINFO}" )) && _FASD_VIMINFO="$HOME/.viminfo"
|
||||
(( "${+_FASD_RECENTLY_USED_XBEL}" )) && \
|
||||
_FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel"
|
||||
|
||||
if [ -z "$_FASD_AWK" ]; then
|
||||
if (( "${+_FASD_AWK}" )); then
|
||||
# awk preferences
|
||||
local awk; for awk in mawk gawk original-awk nawk awk; do
|
||||
$awk "" && _FASD_AWK=$awk && break
|
||||
|
@ -125,7 +125,7 @@ case $1 in
|
|||
# add current pwd if the option is set
|
||||
[ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD"
|
||||
|
||||
[ -z "${paths##\|}" ] && return # stop if we have nothing to add
|
||||
(( "${+paths##\|}" )) && return # stop if we have nothing to add
|
||||
|
||||
# maintain the file
|
||||
local tempfile
|
||||
|
@ -312,12 +312,12 @@ $(fasd --backend $each)"
|
|||
while [ "$1" ]; do case $1 in
|
||||
--complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;;
|
||||
--query|--add|--delete|-A|-D) fasd "$@"; return $?;;
|
||||
--version) [ -z "$comp" ] && echo "1.0.1" && return;;
|
||||
--version) (( "${+comp}" )) && echo "1.0.1" && return;;
|
||||
--) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;;
|
||||
-*) local o="${1#-}"; while [ "$o" ]; do case $o in
|
||||
s*) local show=1;;
|
||||
l*) local lst=1;;
|
||||
i*) [ -z "$comp" ] && local interactive=1 show=1;;
|
||||
i*) (( "${+comp}" )) && local interactive=1 show=1;;
|
||||
r*) local mode=rank;;
|
||||
t*) local mode=recent;;
|
||||
e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e"
|
||||
|
@ -343,7 +343,7 @@ $(fasd --backend $each)"
|
|||
f*) local typ=f;;
|
||||
R*) local r=r;;
|
||||
[0-9]*) local _fasd_i="$o"; break;;
|
||||
h*) [ -z "$comp" ] && echo "fasd [options] [query ...]
|
||||
h*) (( "${+comp}" )) && echo "fasd [options] [query ...]
|
||||
[f|a|s|d|z] [options] [query ...]
|
||||
options:
|
||||
-s list paths with scores
|
||||
|
@ -376,7 +376,7 @@ fasd [-A|-D] [paths ...]
|
|||
fi;;
|
||||
esac
|
||||
|
||||
local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r
|
||||
local R; (( "${+r}" )) && R=r || R= # let $R be the opposite of $r
|
||||
fnd="${fnd# }"
|
||||
|
||||
local res
|
||||
|
@ -407,7 +407,7 @@ fasd [-A|-D] [paths ...]
|
|||
fi
|
||||
if [ "$res" ]; then
|
||||
fasd --add "$res"
|
||||
[ -z "$exec" ] && exec='printf %s\n'
|
||||
(( "${+exec}" )) && exec='printf %s\n'
|
||||
$exec "$res"
|
||||
fi
|
||||
;;
|
||||
|
|
|
@ -6,7 +6,7 @@ fasd_cd() {
|
|||
fasd "$@"
|
||||
else
|
||||
local _fasd_ret="$(fasd -e 'printf %s' "$@")"
|
||||
[ -z "$_fasd_ret" ] && return
|
||||
(( "${+_fasd_ret}" )) && return
|
||||
[ -d "$_fasd_ret" ] && cd "$_fasd_ret" || printf %s\n "$_fasd_ret"
|
||||
fi
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \
|
|||
# zsh word mode completion
|
||||
_fasd_zsh_word_complete() {
|
||||
[ "$2" ] && local _fasd_cur="$2"
|
||||
[ -z "$_fasd_cur" ] && local _fasd_cur="${words[CURRENT]}"
|
||||
(( "${+_fasd_cur}" )) && local _fasd_cur="${words[CURRENT]}"
|
||||
local fnd="${_fasd_cur//,/ }"
|
||||
local typ=${1:-e}
|
||||
fasd --query $typ "$fnd" 2>> "/dev/null" | \
|
||||
|
|
|
@ -12,7 +12,7 @@ local url
|
|||
|
||||
url="$(command git config --file "$(git-root)/.gitmodules" --get "submodule.${src}.url")"
|
||||
|
||||
if [[ -z "${url}" ]]; then
|
||||
if (( "${+url}" )); then
|
||||
print "${0}: submodule not found: ${src}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue