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
()
| 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. |
| 361 | func (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. |
no test coverage detected