[dotfiles-improvement] perf: replace $(date +format) with ZSH prompt expansion \$\{(%):-%D{format}} - #537
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace six
$(date +format)subshell calls across four files with the ZSH-native${(%):-%D{format}}prompt expansion. This usesstrftimeinternally without forking adate(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, passingformattostrftimeinternallyNo subshell or process fork is required.
Affected locations (6 occurrences)
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 betweendate(1)and ZSH'sstrftime, so the generated strings are identical.