Skip to content

Commit 719b315

Browse files
committed
fix: shellcheck SC2004 in dock.sh array subscripts
1 parent e248999 commit 719b315

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

common.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,17 @@ _friendly_val() {
8787
esac
8888
}
8989

90-
# Update terminal tab/window title from breadcrumb stack (e.g. "macrift › Apps › Homebrew")
90+
# Update terminal tab/window title — show path to current menu, not the menu itself
9191
_update_title() {
92-
local title
93-
title=$(IFS=""; echo "${MACRIFT_CRUMBS[*]}")
94-
printf "\033]0;%s\007" "${title:-macrift}"
92+
local count=${#MACRIFT_CRUMBS[@]}
93+
if [[ $count -le 1 ]]; then
94+
printf "\033]0;%s\007" "macrift"
95+
else
96+
local parent=("${MACRIFT_CRUMBS[@]:0:count-1}")
97+
local title
98+
title=$(IFS=""; echo "${parent[*]}")
99+
printf "\033]0;%s\007" "$title"
100+
fi
95101
}
96102

97103
MACRIFT_CRUMBS=()

tweaks/dock.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ hot_corners_tweaks() {
110110
local i
111111

112112
for ((i=0; i<4; i++)); do
113-
orig[$i]=$(defaults read com.apple.dock "${keys[$i]}" 2>/dev/null || echo "0")
114-
vals[$i]="${orig[$i]}"
113+
orig[i]=$(defaults read com.apple.dock "${keys[$i]}" 2>/dev/null || echo "0")
114+
vals[i]="${orig[i]}"
115115
done
116116

117117
crumb_push "Hot Corners"
@@ -169,8 +169,8 @@ hot_corners_tweaks() {
169169
right) if [[ $((cursor % 2)) -eq 0 ]]; then cursor=$((cursor + 1)); else _ui_end; break; fi ;;
170170
space|enter)
171171
local picked
172-
picked=$(_pick_corner_action "${vals[$cursor]}")
173-
vals[$cursor]="$picked"
172+
picked=$(_pick_corner_action "${vals[cursor]}")
173+
vals[cursor]="$picked"
174174
first_draw=true
175175
;;
176176
esac
@@ -179,7 +179,7 @@ hot_corners_tweaks() {
179179
# Check for changes
180180
local has_changes=false
181181
for ((i=0; i<4; i++)); do
182-
[[ "${vals[$i]}" != "${orig[$i]}" ]] && has_changes=true
182+
[[ "${vals[i]}" != "${orig[i]}" ]] && has_changes=true
183183
done
184184

185185
if ! $has_changes; then
@@ -214,7 +214,7 @@ hot_corners_tweaks() {
214214
if ! confirm "Apply?"; then crumb_pop; return; fi
215215

216216
for ((i=0; i<4; i++)); do
217-
defaults write com.apple.dock "${keys[$i]}" -int "${vals[$i]}"
217+
defaults write com.apple.dock "${keys[$i]}" -int "${vals[i]}"
218218
defaults write com.apple.dock "${keys[$i]%%-corner}-modifier" -int 0
219219
done
220220
log_ok "Hot corners applied"

0 commit comments

Comments
 (0)