Skip to content

[dotfiles-improvement] perf: replace $(date +format) with ZSH prompt expansion \$\{(%):-%D{format}} - #537

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/dotfiles-date-prompt-expansion-c871b4b90e97ab19
Draft

[dotfiles-improvement] perf: replace $(date +format) with ZSH prompt expansion \$\{(%):-%D{format}}#537
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/dotfiles-date-prompt-expansion-c871b4b90e97ab19

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Replace six $(date +format) subshell calls across four files with the ZSH-native ${(%):-%D{format}} prompt expansion. This uses strftime internally without forking a date(1) process.

What

${(%):-%D{format}} is a ZSH-native way to produce a formatted timestamp:

  • ${(%):- ... } enables prompt-style expansion on the value
  • %D{format} is the ZSH date format specifier, passing format to strftime internally

No subshell or process fork is required.

Affected locations (6 occurrences)

File Before After
zsh/functions/symlink-sd.zsh $(date +%Y%m%d%H%M%S) ${(%):-%D{%Y%m%d%H%M%S}}
zsh/functions/migrate-laptop.zsh (×2) $(date +%Y%m%d-%H%M%S) ${(%):-%D{%Y%m%d-%H%M%S}}
zsh/functions/claude/functions.zsh $(date +%Y%m%d_%H%M%S) ${(%):-%D{%Y%m%d_%H%M%S}}
zsh/functions/aa-inflight-wifi.zsh (×2) $(date '+%Y-%m-%d %H:%M:%S') ${(%):-%D{%Y-%m-%d %H:%M:%S}}

No behavior change

The format specifiers (%Y, %m, %d, %H, %M, %S) are identical between date(1) and ZSH's strftime, so the generated strings are identical.

Generated by Dotfiles Improvement Scanner · ● 30.6M ·

…mat}}

Replace six $(date +format) subshell calls across four files with the
ZSH-native ${(%):-%D{format}} prompt expansion, which uses strftime
internally without forking a date(1) process.

Affected files (6 occurrences):
- zsh/functions/symlink-sd.zsh: SD backup path timestamp
- zsh/functions/migrate-laptop.zsh: WiFi archive and backup dir names (2×)
- zsh/functions/claude/functions.zsh: settings backup filename
- zsh/functions/aa-inflight-wifi.zsh: log timestamps in main loop (2×)

No behavior change — format strings are identical; strftime produces the
same output as date(1) for these format specifiers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants