Skip to content

[dotfiles-improvement] perf: replace $(hostname)/$(whoami) with ZSH built-ins $HOST/$USER in migrate-laptop.zsh - #547

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/dotfiles-replace-hostname-whoami-zsh-builtins-4773c1e468d19b75
Draft

[dotfiles-improvement] perf: replace $(hostname)/$(whoami) with ZSH built-ins $HOST/$USER in migrate-laptop.zsh#547
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/dotfiles-replace-hostname-whoami-zsh-builtins-4773c1e468d19b75

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What

Two heredoc strings in zsh/functions/migrate-laptop.zsh generate output files using $(hostname) and $(whoami):

# Before (each forks a subprocess)
Machine: $(hostname)
User: $(whoami)

Change

Replace with ZSH built-in parameters:

# After (pure ZSH, no fork)
Machine: $HOST
User: $USER

$HOST is the full hostname and $USER is the current username — both are set by ZSH at startup without spawning a subprocess.

Affected locations (3 occurrences)

  • zsh/functions/migrate-laptop.zshexport-wifi-credentials() README.txt heredoc (1 × $(hostname))
  • zsh/functions/migrate-laptop.zshmigrate-to-new-laptop() MANIFEST.txt heredoc (1 × $(hostname) + 1 × $(whoami))

No behavior change

The values embedded in the generated text files are identical.

Generated by Dotfiles Improvement Scanner · ● 18.7M ·

… migrate-laptop.zsh

$(hostname) and $(whoami) each fork a subprocess; ZSH already sets
$HOST (full hostname) and $USER (current username) at startup with
no fork needed. Replace both occurrences in heredoc strings inside
export-wifi-credentials() and migrate-to-new-laptop() — the text
embedded in the generated README.txt/MANIFEST.txt is identical.

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