Skip to content

Commit bdfa953

Browse files
committed
v3.2.1
1 parent 05b4b6b commit bdfa953

3 files changed

Lines changed: 74 additions & 46 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# SD — Changelog
22

3+
## v3.2.1 (2026-04-24)
4+
* **manpage**: better explanation of `fzf` configurability via `SD_FZF`.
5+
6+
* **fix `set -u` edge case**: running `ds -i` before the first `cd` with
7+
`set -u` enabled previously raised an "unbound variable" error.
8+
9+
* **fix housekeeping edge case**: if initial setup failed, some variables were
10+
not properly unset.
11+
12+
* **default value adjustment**: the power law exponent now defaults to 10 rather
13+
than 9.97. The old value was chosen to make the weight at the midpoint of the
14+
attention window drop to exactly 1/1000; the round value 10 is numerically
15+
equivalent for practical purposes.
16+
317
## v3.2.0 (2026-04-14)
418
* **improved handling of globbing during array construction**: all string-to-array
519
conversions are now executed with globbing temporarily disabled

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ where:
128128
* $p$ is the power-law exponent
129129
* $n_i$ are the event indices within the window at which directory $i$ was visited
130130

131-
Higher $p$ increases recency bias. Default: $p = 9.97$.
131+
Higher $p$ increases recency bias. Default: $p = 10$.
132132

133133
Properties:
134134

@@ -218,7 +218,7 @@ Define only the keys you want to override:
218218
typeset -A SD_CFG=(
219219
[loglim]=8192
220220
[window]=1280
221-
[power]=9.97
221+
[power]=10
222222
[stacklim]=0
223223
[smartcase]=1
224224
[verbose]=1

‎sd.ksh‎

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function _sd__man { ## pdf?
8787

8888
cat <<-HERE | "${formatter[@]}" | "${pager[@]}"
8989
.\"----------------------------------------------------------
90-
.TH SD 1 "January 25, 2026"
90+
.TH SD 1 "April 16, 2026"
9191
.nh
9292
.SH NAME
9393
sd \- switch between directories using a dynamic directory stack
@@ -257,8 +257,8 @@ do no longer trigger directory stack updates, making the stack content
257257
"static" (stack recomputation is still triggered by any of
258258
.B ds
259259
.BR "\-[cdefkl]" ).
260-
This also ensures invariant rank order on the stack which sometimes might be desirable.
261-
Current state:
260+
This also ensures invariant rank order on the stack which sometimes might be
261+
desirable. Current state:
262262
.BR ${offon[SD_CFG[dynamic]]} .
263263
.TP
264264
.B \-p
@@ -340,8 +340,8 @@ users must quote the equal sign.
340340
.LP
341341
The
342342
.B ds
343-
command serves two purposes. With an option, it acts as a configuration, management,
344-
and inspection interface. As
343+
command serves two purposes. With an option, it acts as a configuration,
344+
management, and inspection interface. As
345345
.B ds
346346
.IR pattern ,
347347
it provides interactive selection from matching stack entries. If
@@ -359,19 +359,19 @@ opens the
359359
interface
360360
(mode
361361
.BR 2 ).
362+
If
363+
.B ds
364+
.I pattern
365+
yields a unique match, cd executes immediately.
362366
.B fzf
363-
is non-standard and may require separate installation.
367+
is non-standard and may require separate installation. By default,
364368
.B fzf
365-
displays the stack bottom-up by default (highest ranking match at bottom), with the
366-
entry initially selected being the one
369+
displays the stack bottom-up (highest ranking match at bottom), with
370+
the entry initially selected being the one
367371
.B sd
368372
.I pattern
369373
would have chosen. Selection is done at the fzf prompt or via mouse (see
370374
.BR fzf (1)).
371-
If
372-
.B ds
373-
.I pattern
374-
has a unique match, by default cd executes immediately without opening fzf.
375375
Selecting a stale entry in fzf will fail, whereas
376376
.B sd
377377
.I pattern
@@ -472,7 +472,7 @@ Limitations
472472
.LP
473473
Due to the internal use of tab-separated fields for stack representation,
474474
directory names containing tab characters are not supported. Such paths may
475-
lead to incorrect matching or display behavior and should be avoided.
475+
lead to incorrect matching or display behaviour and should be avoided.
476476
.
477477
.
478478
.SH SHELL VARIABLES AND FUNCTIONS
@@ -483,7 +483,7 @@ User-visible internal variables follow
483483
.BR SD__VARNAME .
484484
The associative array
485485
.B SD_CFG
486-
holds configuration information. Default behavior can be changed by modifying
486+
holds configuration information. Default behaviour can be changed by modifying
487487
this array in your shell rc file (see
488488
.IR CUSTOMIZATION ).
489489
Some
@@ -523,7 +523,7 @@ typeset \-A SD_CFG=(
523523
[loglim]=${SD__LOGLIM}${pad[loglim]} # max. cd actions in logfile (\fB**\fP)
524524
[dynamic]=${SD_CFG[dynamic]}${pad[dynamic]} # auto-update stack after each cd?
525525
[freeze]=${SD_CFG[freeze]}${pad[freeze]} # freeze logfile? (usually: don't)
526-
[mode]=${SD_CFG[mode]}${pad[mode]} # controls behavior of \fBds \fIpattern\fR
526+
[mode]=${SD_CFG[mode]}${pad[mode]} # controls behaviour of \fBds \fIpattern\fR
527527
[period]=${SD_CFG[period]}${pad[period]} # flush delay period in seconds
528528
[power]=${SD_CFG[power]}${pad[power]} # power exponent for score computation
529529
[prefix]='${SD_CFG[prefix]}'${pad[prefix]} # prefix char for \fBcd \fI=num\fR actions
@@ -564,43 +564,54 @@ respectively.
564564
.SS "fzf behaviour
565565
.LP
566566
.B fzf
567-
behaviour is customized by defining entries in the associative array
567+
behaviour is customized via the associative array
568568
.BR SD_FZF ,
569-
using fzf long option names without the -- prefix as keys, for example:
569+
using long option names (without the leading
570+
.BR -- )
571+
as keys. Options that do not take a value are specified in
572+
.B SD_FZF
573+
with an empty value, for example:
570574
.LP
571575
.EX
572-
typeset \-A SD_FZF=(
573-
[exact]=''
574-
[layout]='default'
576+
typeset -A SD_FZF=(
577+
[cycle]=''
578+
[tmux]='center,80%,border-native'
575579
)
576580
.EE
577581
.LP
578-
Options that take no value are specified with an empty string as value.
579-
As with
580-
.BR SD_CFG ,
581-
custom definitions of
582-
.BR SD_FZF
583-
keys should be put in the shell rc file prior to sourcing
584-
.BR sd.ksh .
585-
Note that the fzf options
582+
User-defined entries in
583+
.B SD_FZF
584+
may be set either before or after sourcing
585+
.B sd.ksh
586+
and generally override internal defaults. The only exception is the default
587+
definition
588+
.BR SD_FZF[exact]='' .
589+
To disable the
590+
.B --exact
591+
option, unset the entry
592+
.I after
593+
sourcing
594+
.BR sd.ksh :
595+
.LP
596+
.EX
597+
unset SD_FZF[exact]
598+
.EE
599+
.LP
600+
The options
586601
.B --preview
587602
and
588603
.B --no-sort
589604
are set internally by
590605
.B SD
591606
and cannot be overridden via
592607
.BR SD_FZF .
593-
None of the
594-
.BR SD_FZF
595-
keys are exposed via dedicated
608+
No dedicated
596609
.B ds
597-
options; manual redefinition of
598-
.B SD_FZF
599-
keys is possible if transient changes are needed.
600-
The current
601-
.B SD_FZF
610+
options exist for modifying
611+
.BR SD_FZF ;
612+
transient changes may be made by editing the array directly. The current
602613
configuration can be inspected with
603-
.BR "typeset -p SD_FZF" .
614+
.BR "typeset -p SD_FZF.
604615
.
605616
.
606617
.SH DIRECTORY STACK ALGORITHM
@@ -666,7 +677,7 @@ Source the script in your shell resource file:
666677
.LP
667678
This line may be preceded by
668679
.B SD_CFG
669-
array definition to customize behavior (see
680+
array definition to customize behaviour (see
670681
.IR CUSTOMIZATION ).
671682
.LP
672683
.B SD
@@ -798,19 +809,20 @@ function _sd__setup {
798809
# now set the other SD_CFG keys (do this before the failure tests block since on first use user is
799810
# offered to view manpage immediately -- and the manpage reports the values).
800811
typeset -i mode
812+
typeset -i window=1280
801813
command -v fzf >/dev/null
802814
((mode = $? == 0? 2:1))
803815
: "${SD_CFG[dynamic]:="1"}"
804816
: "${SD_CFG[freeze]:="0"}"
805817
: "${SD_CFG[mode]:="$mode"}"
806818
: "${SD_CFG[period]:="3600"}"
807-
: "${SD_CFG[power]:="9.97"}"
819+
: "${SD_CFG[power]:="10"}"
808820
: "${SD_CFG[prefix]:="="}"; [[ ${SD_CFG[prefix]} == [=:,+?] ]] || SD_CFG[prefix]='='
809821
: "${SD_CFG[smartcase]:="1"}"
810822
: "${SD_CFG[stacklim]:="0"}"
811823
: "${SD_CFG[verbose]:="1"}"
812-
: "${SD_CFG[window]:="1280"}"
813-
[[ ${SD_CFG[window]} != [1-9]*([0-9]) ]] && SD_CFG[window]=1280 # guard against nonsensical user config specification, notably window=0
824+
: "${SD_CFG[window]:="$window"}"
825+
[[ ${SD_CFG[window]} != [1-9]*([0-9]) ]] && SD_CFG[window]="$window" # guard against nonsensical user config specification, notably window=0
814826

815827
: "${SD_FZF[bind]:="ctrl-j:accept"}"
816828
: "${SD_FZF[color]:="header:bright-red"}"
@@ -833,7 +845,10 @@ function _sd__setup {
833845
: "${SD__INTERN[mysd]:="0"}"
834846
: "${SD__INTERN[mysdset]:="0"}"
835847
: "${SD__INTERN[sleep]:="0.01"}"
836-
: "${SD__INTERN[version]:="3.2.0"}"
848+
: "${SD__INTERN[version]:="3.2.1"}"
849+
850+
: "${SD__STACK:=""}"
851+
: "${SD__NEW:=""}"
837852

838853
typeset -i failure=0
839854
if [[ ${SD__LOGDIR} != /* ]]; then
@@ -892,7 +907,7 @@ function _sd__setup {
892907
_sd__logappend _sd__logcheck _sd__logread _sd__logwrite _sd__man _sd__match \
893908
_sd__name _sd__remove _sd__seed _sd__checkshell _sd__stack _sd__wincalc
894909

895-
unset SD_CFG SD__STATE SD__INTERN
910+
unset SD_CFG SD_FZF SD__STATE SD__INTERN SD__STACK SD__NEW
896911
unset SD__LOGDIR SD__LOGLIM SD__LOGFILE SD__LOCK SD__MAGIC SD__TRPCMD
897912
return $failure
898913
else
@@ -1450,7 +1465,6 @@ function _sd__switch { ## regex
14501465
(( SD_CFG[dynamic] )) && _sd__stack
14511466
fi
14521467
if (( SECONDS > SD__STATE[stamp] + SD_CFG[period] )); then
1453-
(( SD__INTERN[debug] )) && printf '%s' "$SD__NEW"
14541468
_sd__logappend
14551469
fi
14561470
}

0 commit comments

Comments
 (0)