diff --git a/base/arch-desktop/bin/bspc-focus b/base/arch-desktop/bin/bspc-focus
index c9b940f5..a7e1f753 100755
--- a/base/arch-desktop/bin/bspc-focus
+++ b/base/arch-desktop/bin/bspc-focus
@@ -24,7 +24,7 @@ case $dir in west|south|north|east) ;;
exit 1
esac
-if [[ $leap ]]; then
+if [[ -n $leap ]]; then
# jump to monitor in direction
bspc monitor -f "$dir"
else
diff --git a/base/arch-desktop/bin/bspc-swap b/base/arch-desktop/bin/bspc-swap
index 5bea54a6..86ca3ad9 100755
--- a/base/arch-desktop/bin/bspc-swap
+++ b/base/arch-desktop/bin/bspc-swap
@@ -26,7 +26,7 @@ case $dir in west|south|north|east) ;;
exit 1
esac
-if [[ $leap ]]; then
+if [[ -n $leap ]]; then
# move window to monitor in direction
old_id=$(bspc query -N -n focused)
if [[ $(bspc query -M -m "$dir") ]]; then
@@ -38,7 +38,7 @@ else
old_id=$(bspc query -N -n focused)
if bspc node -s "$dir.local"; then
bspc node -f "$old_id"
- elif [[ $(bspc query -M -m "$dir") ]]; then
+ elif [[ -n $(bspc query -M -m "$dir") ]]; then
bspc node -m "$dir"
bspc node -f "$old_id"
fi
diff --git a/base/arch-desktop/bin/rsl b/base/arch-desktop/bin/rsl
index efd97c0d..e741a596 100755
--- a/base/arch-desktop/bin/rsl
+++ b/base/arch-desktop/bin/rsl
@@ -7,7 +7,7 @@ if command -v xdg-open >/dev/null; then
open=xdg-open
elif command -v open >/dev/null; then
open=open
-elif [[ $BROWSER ]]; then
+elif [[ -n $BROWSER ]]; then
open=firefox
else
>&2 echo "No program to open urls with"
diff --git a/base/arch-desktop/bin/urxvt-pass-manager b/base/arch-desktop/bin/urxvt-pass-manager
index 154efe9d..7bbb0360 100755
--- a/base/arch-desktop/bin/urxvt-pass-manager
+++ b/base/arch-desktop/bin/urxvt-pass-manager
@@ -7,7 +7,7 @@
# Get firefox's current url; requires "Hostname in title" plugin for firefox
win=$(xdotool getactivewindow)
-if [[ $win ]]; then
+if [[ -n $win ]]; then
winname=$(xdotool getwindowname $win)
if [[ $winname =~ " - Mozilla Firefox$" ]]; then
url=${winname% - Mozilla*}
@@ -26,4 +26,4 @@ urxvt -name urxvt-fuzzy \
-e $SHELL \
-c "fzf-pass $@ $url"
-[[ $win ]] && xdotool windowactivate $win
+[[ -n $win ]] && xdotool windowactivate $win
diff --git a/base/arch-desktop/bin/urxvt-scratch-window b/base/arch-desktop/bin/urxvt-scratch-window
index 5a00d48d..49a481b9 100755
--- a/base/arch-desktop/bin/urxvt-scratch-window
+++ b/base/arch-desktop/bin/urxvt-scratch-window
@@ -3,7 +3,7 @@ SCRID=urxvt-scratch
focused=$(xdotool getactivewindow)
scratch=$(xdotool search --onlyvisible --classname $SCRID)
-if [[ $scratch ]]; then
+if [[ -n $scratch ]]; then
if [[ $focused == $scratch ]]; then
tmux kill-session -t scratch
else
diff --git a/base/arch-desktop/bin/vol b/base/arch-desktop/bin/vol
index 438e89cd..78117a95 100755
--- a/base/arch-desktop/bin/vol
+++ b/base/arch-desktop/bin/vol
@@ -4,7 +4,7 @@ if (($# == 0)); then
data=$(amixer get Master)
vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
state=$(echo "$data" | grep '\[on\]')
- [[ $state ]] && echo $vol || echo 0
+ [[ -n $state ]] && echo $vol || echo 0
exit
fi
diff --git a/base/arch/scripts/bootstrap.sh b/base/arch/scripts/bootstrap.sh
index f3556720..6e3aa20a 100755
--- a/base/arch/scripts/bootstrap.sh
+++ b/base/arch/scripts/bootstrap.sh
@@ -41,13 +41,13 @@ pac dosfstools ntfs-3g exfat-utils hfsprogs
# networking support
WIRELESS_DEV=$(ip link | grep wlp | awk '{print $2}'| sed 's/://' | sed '1!d')
-if [[ $WIRELESS_DEV ]]; then
+if [[ -n $WIRELESS_DEV ]]; then
echo "==> ${WIRELESS_DEV} interface detected"
pac iw wireless_tools wpa_actiond wpa_supplicant dialog netctl
fi
WIRED_DEV=$(ip link | grep "en[sop]" | awk '{print $2}'| sed 's/://' | sed '1!d')
-if [[ $WIRED_DEV ]]; then
+if [[ -n $WIRED_DEV ]]; then
echo "==> ${WIRED_DEV} interface detected"
arch "systemctl enable dhcpcd@${WIRED_DEV}.service"
fi
diff --git a/bin/imgoptim b/bin/imgoptim
index 00e3cc68..03bf63a0 100755
--- a/bin/imgoptim
+++ b/bin/imgoptim
@@ -46,14 +46,14 @@ done
shift $((OPTIND-1))
cmds=( optipng jpegtran gifsicle )
-[[ $lossy ]] && cmds=( $cmds pngquant jpegoptim )
+[[ -n $lossy ]] && cmds=( $cmds pngquant jpegoptim )
for cmd in ${cmds[@]}; do
if ! command -v $cmd >/dev/null; then
>&2 echo "$cmd isn't installed"
error=1
fi
done
-if [[ $error ]]; then
+if [[ -n $error ]]; then
>&2 echo "There were errors, aborting"
exit 1
fi
@@ -65,14 +65,14 @@ for file in $@; do
pre_size=$(_filesize "$file")
case ${file##*.} in
png)
- [[ $lossy ]] && pngquant $file
+ [[ -n $lossy ]] && pngquant $file
optipng -nc -nb -o7 $file
;;
gif)
gifsicle --batch --optimize=3 "$file"
;;
jpg|jpeg)
- [[ $lossy ]] && jpegoptim --max=90 "$file"
+ [[ -n $lossy ]] && jpegoptim --max=90 "$file"
jpegtran -copy none -optimize -progressive -outfile "$file" "$file"
;;
*)
diff --git a/bin/myip b/bin/myip
index e0d39758..fde1b934 100755
--- a/bin/myip
+++ b/bin/myip
@@ -6,7 +6,7 @@ if [[ $1 == -w ]]; then
shift
fi
-if [[ $wan ]]; then
+if [[ -n $wan ]]; then
dig +short myip.opendns.com @resolver1.opendns.com
else
IF=$(netstat -rn | awk '/^0.0.0.0/ {thif=substr($0,74,10); print thif;} /^default.*UG/ {thif=substr($0,65,10); print thif;}')
diff --git a/bin/rclip b/bin/rclip
index 40c68134..20286037 100755
--- a/bin/rclip
+++ b/bin/rclip
@@ -33,7 +33,7 @@ done
shift $((OPTIND-1))
target="$1"
-if [[ $target ]]; then
+if [[ -n $target ]]; then
if [[ -t 0 ]]; then
pb | $bin $target
else
diff --git a/bin/sup b/bin/sup
index 52574e50..1663c99c 100644
--- a/bin/sup
+++ b/bin/sup
@@ -65,17 +65,17 @@ delay() {
}
screenshot() {
- if [[ $doFullscreen ]]; then
+ if [[ -n $doFullscreen ]]; then
cap_fullscreen
- elif [[ $doSelection ]]; then
+ elif [[ -n $doSelection ]]; then
cap_selection &>/dev/null
if ! [[ -s $local_file ]]; then
$(rm "$local_file" 2> /dev/null)
exit
fi
- elif [[ $doWindow ]]; then
+ elif [[ -n $doWindow ]]; then
cap_window
- elif [[ $doURL ]]; then
+ elif [[ -n $doURL ]]; then
local urlext
if [[ -f /usr/share/mime/globs ]]; then
urlext=$(curl -sf --head "${remoteURL}" | grep 'Content-Type: ' | head -1 | grep -Po '(?<=\ )[^\;]*')
@@ -147,7 +147,7 @@ upload() {
shortenerResult="$(curl -sf -F c=@- "${shortenerURL}" <<< "${uploadResult}")"
fi
- if [[ $shortener ]]; then
+ if [[ -n $shortener ]]; then
finalResult="$shortenerResult"
else
finalResult="$uploadResult"
diff --git a/dev/lua/_init b/dev/lua/_init
index 02f1eaf4..1635d64a 100644
--- a/dev/lua/_init
+++ b/dev/lua/_init
@@ -9,7 +9,7 @@ install() {
}
update() {
- if [[ $LUAENV_ROOT ]]; then
+ if [[ -n $LUAENV_ROOT ]]; then
cd $LUAENV_ROOT && git pull
for ver in $LUAENV_ROOT/plugins/*(/); do
cd $ver && git pull
diff --git a/dev/node/_init b/dev/node/_init
index b7ed6d0c..376b0bff 100755
--- a/dev/node/_init
+++ b/dev/node/_init
@@ -8,7 +8,7 @@ install() {
}
update() {
- if [[ $NODENV_ROOT ]]; then
+ if [[ -n $NODENV_ROOT ]]; then
cd $NODENV_ROOT && git pull
for ver in $NODENV_ROOT/plugins/*(/); do
cd $ver && git pull
diff --git a/dev/python/_init b/dev/python/_init
index 819b0417..5d746b66 100755
--- a/dev/python/_init
+++ b/dev/python/_init
@@ -7,7 +7,7 @@ install() {
}
update() {
- if [[ $PYENV_ROOT ]]; then
+ if [[ -n $PYENV_ROOT ]]; then
cd $PYENV_ROOT && git pull
for ver in $PYENV_ROOT/plugins/*(/N); do
cd $ver && git pull
diff --git a/dev/ruby/_init b/dev/ruby/_init
index 6f92c085..9af81825 100755
--- a/dev/ruby/_init
+++ b/dev/ruby/_init
@@ -8,7 +8,7 @@ install() {
}
update() {
- if [[ $RBENV_ROOT ]]; then
+ if [[ -n $RBENV_ROOT ]]; then
cd $RBENV_ROOT && git pull
for ver in $RBENV_ROOT/plugins/*(/N); do
cd $ver && git pull
diff --git a/shell/fzf/bin/fzf-apps b/shell/fzf/bin/fzf-apps
index 941e1b7c..a3078a45 100755
--- a/shell/fzf/bin/fzf-apps
+++ b/shell/fzf/bin/fzf-apps
@@ -8,11 +8,11 @@ FZF_DEFAULT_OPTS="--prompt='open > ' $FZF_DEFAULT_OPTS"
case $OSTYPE in
darwin*)
cmd=$(find -L {,~}/Applications -iname '*.app' -maxdepth 2 -type d 2>/dev/null | sort -u | fzf)
- [[ $cmd ]] && open "$cmd"
+ [[ -n $cmd ]] && open "$cmd"
;;
linux*)
cmd=$(echo -n "$PATH" | xargs -d: -I{} -r -- find -L {} -maxdepth 1 -mindepth 1 -type f -executable -printf '%P\n' 2>/dev/null | sort -u | fzf)
- if [[ ! $cmd ]]; then
+ if [[ -z $cmd ]]; then
return
elif [[ $cmd == fzf-* ]]; then
$cmd
diff --git a/shell/fzf/bin/fzf-kill b/shell/fzf/bin/fzf-kill
index c087d738..55489acc 100755
--- a/shell/fzf/bin/fzf-kill
+++ b/shell/fzf/bin/fzf-kill
@@ -4,6 +4,6 @@
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
-if [[ $pid ]]; then
+if [[ -n $pid ]]; then
xargs kill -${1:-9} <<< "$pid"
fi
diff --git a/shell/fzf/bin/fzf-mpc b/shell/fzf/bin/fzf-mpc
index 41b41e5e..adbc5d24 100755
--- a/shell/fzf/bin/fzf-mpc
+++ b/shell/fzf/bin/fzf-mpc
@@ -8,4 +8,4 @@ set -e
song=$(mpc -f "%position%) %artist% - %title%" playlist)
song_index=$(fzf --query="$1" --select-1 --exit-0 --prompt='play > ' <<<"$song" | sed -n 's/^\([0-9]\+\)).*/\1/p')
-[[ $song_index ]] && mpc -q play "$song_index"
+[[ -n $song_index ]] && mpc -q play "$song_index"
diff --git a/shell/fzf/bin/fzf-pass b/shell/fzf/bin/fzf-pass
index 938754fb..4c52d263 100755
--- a/shell/fzf/bin/fzf-pass
+++ b/shell/fzf/bin/fzf-pass
@@ -16,7 +16,7 @@ fi
url=$@
LAST_ENTRY_FILE=/tmp/_upm
-if [[ $resume && -f $LAST_ENTRY_FILE ]]; then
+if [[ -n $resume && -f $LAST_ENTRY_FILE ]]; then
entry="$(<$LAST_ENTRY_FILE)"
last=1
else
@@ -34,7 +34,7 @@ fi
echo "$entry" >/tmp/_upm
secrets="$(pass show "$entry")"
-if [[ $secrets ]]; then
+if [[ -n $secrets ]]; then
fields=$(awk -F': ' 'NR>1 && !/^otpauth:/ {print $1}' <<<"$secrets")
field=$(printf "password\n%s\notp\n" "${fields[@]}" | fzf --prompt="pass ($entry) > ")
case $field in
diff --git a/shell/mpd+ncmpcpp/bin/mpd-notify-song b/shell/mpd+ncmpcpp/bin/mpd-notify-song
index a9ac99a2..b9ca67fd 100755
--- a/shell/mpd+ncmpcpp/bin/mpd-notify-song
+++ b/shell/mpd+ncmpcpp/bin/mpd-notify-song
@@ -34,7 +34,7 @@ case $(grep "$file" "$playlist_dir"/*-star.m3u) in
*/4-star.m3u:*) starn=4 ;;
*/5-star.m3u:*) starn=5 ;;
esac
-if [[ $starn ]]; then
+if [[ -n $starn ]]; then
star_filled_icon="★"
star_empty_icon="☆"
if [[ $OSTYPE == linux* ]]; then
@@ -53,12 +53,12 @@ fi
case $OSTYPE in
darwin*)
- [[ $rating ]] && rating="[$rating] "
+ [[ -n $rating ]] && rating="[$rating] "
killall terminal-notifier
terminal-notifier -title "$rating$title" -message "by $artist :: $album" -appIcon "/Applications/iTunes.app/Contents/Resources/iTunes.icns" &
;;
linux*)
- [[ $rating ]] && rating="$rating
"
+ [[ -n $rating ]] && rating="$rating
"
notify-send --urgency=low --icon="media-playback-start" --app-name="ncmpcpp" "$rating$title" "${artist}\n${album}" &
;;
esac >/dev/null 2>&1
diff --git a/shell/tmux/_init b/shell/tmux/_init
index 1f93521b..61b2d5f2 100755
--- a/shell/tmux/_init
+++ b/shell/tmux/_init
@@ -9,7 +9,7 @@ install() {
debian) sudo apt-get install -y tmux ;;
esac
- [[ $TMUXIFIER ]] && _ensure_repo jimeh/tmuxifier $TMUXIFIER
+ [[ -n $TMUXIFIER ]] && _ensure_repo jimeh/tmuxifier $TMUXIFIER
}
update() {
diff --git a/shell/tmux/aliases.zsh b/shell/tmux/aliases.zsh
index 20cee14e..103cf26e 100644
--- a/shell/tmux/aliases.zsh
+++ b/shell/tmux/aliases.zsh
@@ -3,7 +3,7 @@ alias tmux='tmux -f "$TMUX_HOME/tmux.conf"'
alias ta='tmux attach'
alias tl='tmux ls'
-if [[ $TMUX ]]; then # From inside tmux
+if [[ -n $TMUX ]]; then # From inside tmux
alias tf='tmux find-window'
# Detach all other clients to this session
alias mine='tmux detach -a'
diff --git a/shell/tmux/bin/tmux-session-name b/shell/tmux/bin/tmux-session-name
index 8cc07efc..d37bd7d1 100755
--- a/shell/tmux/bin/tmux-session-name
+++ b/shell/tmux/bin/tmux-session-name
@@ -3,5 +3,5 @@
id=$(echo $TMUX | sed 's/.*,//g')
res=$(tmux ls -F '#{session_id}:#{session_name}' | grep -e "^\$$id:")
-[[ $res ]] || exit 1
+[[ -z $res ]] && exit 1
echo "${res#\$$id:}"
diff --git a/shell/zsh/prompt.zsh b/shell/zsh/prompt.zsh
index a13f30ec..1515f62e 100644
--- a/shell/zsh/prompt.zsh
+++ b/shell/zsh/prompt.zsh
@@ -23,13 +23,13 @@ prompt_git_dirty() {
prompt_hook_precmd() {
vcs_info # get git info
# Newline before prompt, except on init
- [[ $PROMPT_DONE ]] && print ""; PROMPT_DONE=1
+ [[ -n $PROMPT_DONE ]] && print ""; PROMPT_DONE=1
}
## Initialization ######################
prompt_init() {
# prevent the extra space in the rprompt
- [[ $EMACS ]] || ZLE_RPROMPT_INDENT=0
+ [[ -n $EMACS ]] || ZLE_RPROMPT_INDENT=0
# prevent percentage showing up
# if output doesn't end with a newline
export PROMPT_EOL_MARK=
@@ -59,7 +59,7 @@ prompt_init() {
zstyle ':vcs_info:git*' actionformats ' %b (%a)'
# show username@host if logged in through SSH
- if [[ $SSH_CONNECTION ]]; then
+ if [[ -n $SSH_CONNECTION ]]; then
prompt_username='%m '
if [[ $(whoami) != hlissner ]]; then
prompt_username="%n.$prompt_username"