shell-scripts: Use [[ instead of [ where possible

Replace all occurrences of [ with [[ in bash and zsh scripts and
configs.
Performance wise it makes sense to use the builtin instead of calling an
external command also when from a functionality stand point `test` would
suffice.
This commit is contained in:
2020-10-03 01:29:29 +02:00
parent 29d28a25ee
commit 4cb445c2b5
14 changed files with 64 additions and 64 deletions

View File

@@ -69,7 +69,7 @@ zle -N _expandDots
bindkey . _expandDots
function ls-on-enter {
if [ -z "$BUFFER" ]; then
if [[ -z "$BUFFER" ]]; then
BUFFER=ls
zle accept-line
else
@@ -85,7 +85,7 @@ ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(ls-on-enter)
# "Scroll" through history if buffer was empty but use it as query for fzf over
# command line history if not (similar to substring-search but with fzf)
function fzf-hist-up {
if [ -z "$BUFFER" ] || [ "$FZF_HIST_WENT_UP" -eq 1 ]; then
if [[ -z "$BUFFER" || "$FZF_HIST_WENT_UP" -eq 1 ]]; then
zle up-line-or-history
FZF_HIST_WENT_UP=1
else
@@ -95,7 +95,7 @@ function fzf-hist-up {
}
function fzf-hist-down {
zle down-line-or-history
[ -n "$BUFFER" ] || FZF_HIST_WENT_UP=
[[ -n "$BUFFER" ]] || FZF_HIST_WENT_UP=
}
zle -N fzf-hist-up
zle -N fzf-hist-down