MCPcopy Index your code
hub / github.com/jetify-com/devbox / aliasLines

Method aliasLines

internal/devbox/shell.go:361–381  ·  view source on GitHub ↗

aliasLines returns the shell `alias` commands for the aliases defined in devbox.json, sorted by alias name for deterministic output. The returned lines use the current shell's builtin `alias` command (which is compatible across bash, zsh, and fish) and are injected into the shellrc after the init ho

()

Source from the content-addressed store, hash-verified

359// across bash, zsh, and fish) and are injected into the shellrc after the init
360// hook is sourced. It returns nil when there are no aliases or no config.
361func (s *DevboxShell) aliasLines() []string {
362 if s.devbox == nil || s.devbox.Config() == nil {
363 return nil
364 }
365 aliases := s.devbox.Config().Aliases()
366 if len(aliases) == 0 {
367 return nil
368 }
369
370 names := make([]string, 0, len(aliases))
371 for name := range aliases {
372 names = append(names, name)
373 }
374 sort.Strings(names)
375
376 lines := make([]string, 0, len(names))
377 for _, name := range names {
378 lines = append(lines, fmt.Sprintf("alias %s=%s", name, s.quoteAliasValue(aliases[name])))
379 }
380 return lines
381}
382
383// quoteAliasValue single-quotes an alias value so it is passed verbatim to the
384// shell's `alias` builtin, escaping any embedded quotes for the current shell.

Callers 1

writeDevboxShellrcMethod · 0.95

Calls 3

quoteAliasValueMethod · 0.95
AliasesMethod · 0.80
ConfigMethod · 0.65

Tested by

no test coverage detected