Use arithmetic conditionals for numeric tests in bin

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-07-24 12:25:20 -07:00
co-authored by Claude Opus 5
parent f15a91cbe2
commit d407454511
7 changed files with 12 additions and 12 deletions
+4 -4
View File
@@ -43,7 +43,7 @@ bar_option_exists() {
cmd_use() {
local plugin="${1:-}"
[[ -n $plugin ]] || fail "bar option id is required"
[[ $# -eq 1 ]] || fail "use takes a single bar option id"
(( $# == 1 )) || fail "use takes a single bar option id"
if [[ $plugin == "default" || $plugin == "built-in" ]]; then
plugin="omarchy.bar"
fi
@@ -74,7 +74,7 @@ cmd_defaults() {
cmd_position() {
local position="${1:-}"
[[ -n $position ]] || fail "position is required"
[[ $# -eq 1 ]] || fail "position takes a single value"
(( $# == 1 )) || fail "position takes a single value"
[[ $position =~ ^(top|bottom|left|right)$ ]] || fail "position must be top, bottom, left, or right"
commit "$NORMALIZE | .bar.position = \$position" --arg position "$position"
echo "Bar position set to $position"
@@ -83,7 +83,7 @@ cmd_position() {
cmd_transparent() {
local transparent="${1:-}"
[[ -n $transparent ]] || fail "transparent is required"
[[ $# -eq 1 ]] || fail "transparent takes a single value"
(( $# == 1 )) || fail "transparent takes a single value"
[[ $transparent =~ ^(true|false|toggle)$ ]] || fail "transparent must be true, false, or toggle"
if [[ $transparent == "toggle" ]]; then
commit "$NORMALIZE | .bar.transparent = (.bar.transparent != true)"
@@ -97,7 +97,7 @@ cmd_transparent() {
# --------------------------------------------------------------------- dispatch
command="${1:-}"
[[ $# -gt 0 ]] && shift || true
(( $# > 0 )) && shift || true
case "$command" in
use)
+2 -2
View File
@@ -416,7 +416,7 @@ cmd_replace() {
local new="${2:-}"
[[ -n $old ]] || fail "replace requires the source widget id"
[[ -n $new ]] || fail "replace requires the replacement widget id"
[[ $# -eq 2 ]] || fail "replace takes two widget ids"
(( $# == 2 )) || fail "replace takes two widget ids"
local prog
prog=$(cat <<JQ
@@ -439,7 +439,7 @@ JQ
# --------------------------------------------------------------------- dispatch
command="${1:-}"
[[ $# -gt 0 ]] && shift || true
(( $# > 0 )) && shift || true
case "$command" in
add)
+1 -1
View File
@@ -8,7 +8,7 @@
history_index=""
history_path="$HOME/.local/state/omarchy/clipboard-history.json"
while [[ $# -gt 0 ]]; do
while (( $# > 0 )); do
case "$1" in
--history-index)
history_index="${2:-}"
+1 -1
View File
@@ -11,7 +11,7 @@ copy_only=false
history_index=""
text=""
while [[ $# -gt 0 ]]; do
while (( $# > 0 )); do
case "$1" in
--shift-insert)
use_shift_insert=true
+2 -2
View File
@@ -151,7 +151,7 @@ plugin_enabled() {
[[ -n $id ]] || fail "plugin id is required"
shift 2
if [[ $enabled != "true" && $# -gt 0 ]]; then
if [[ $enabled != "true" ]] && (( $# > 0 )); then
fail "disable does not take placement options"
fi
@@ -165,7 +165,7 @@ plugin_enabled() {
result=$(omarchy-shell shell setPluginEnabled "$id" "$enabled") || fail "could not update plugin; is omarchy-shell running?"
[[ $result == "ok" ]] || fail "plugin '$id' is not known; run: omarchy plugin rescan"
if [[ $enabled == "true" && $# -gt 0 ]]; then
if [[ $enabled == "true" ]] && (( $# > 0 )); then
omarchy-bar-plugin move "$id" "$@"
echo "Enabled and moved $id"
elif [[ $enabled == "true" ]]; then
+1 -1
View File
@@ -89,7 +89,7 @@ authorize_keys_from_github() {
authorize_key "$key" && added=$((added + 1))
done <<<"$keys"
if [[ $added -eq 0 ]]; then
if (( added == 0 )); then
echo -e "\e[31mNo valid SSH keys found for GitHub user '$username'.\e[0m" >&2
exit 1
fi
+1 -1
View File
@@ -26,7 +26,7 @@ usage() {
echo "Usage: omarchy-theme-color [--file <colors.toml>] (--all | --raw | <key> [fallback])"
}
while [[ $# -gt 0 ]]; do
while (( $# > 0 )); do
case "$1" in
--file)
COLORS_FILE="${2:-}"