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

Function initShellBinaryFields

internal/devbox/shell.go:142–179  ·  view source on GitHub ↗

initShellBinaryFields initializes the fields specific to the shell binary that will be used for the devbox shell.

(path string)

Source from the content-addressed store, hash-verified

140// initShellBinaryFields initializes the fields specific to the shell binary that will be used
141// for the devbox shell.
142func initShellBinaryFields(path string) *DevboxShell {
143 shell := &DevboxShell{binPath: path}
144 base := filepath.Base(path)
145 // Login shell
146 if base[0] == '-' {
147 base = base[1:]
148 }
149 switch base {
150 case "bash":
151 shell.name = shBash
152 shell.userShellrcPath = rcfilePath(".bashrc")
153 case "zsh":
154 shell.name = shZsh
155 if zdotdir := os.Getenv("ZDOTDIR"); zdotdir != "" {
156 shell.userShellrcPath = filepath.Join(os.ExpandEnv(zdotdir), ".zshrc")
157 } else {
158 shell.userShellrcPath = rcfilePath(".zshrc")
159 }
160 case "ksh":
161 shell.name = shKsh
162 shell.userShellrcPath = rcfilePath(".kshrc")
163 case "fish":
164 shell.name = shFish
165 shell.userShellrcPath = fishConfig()
166 case "dash", "ash", "shell":
167 shell.name = shPosix
168 shell.userShellrcPath = os.Getenv(envir.Env)
169
170 // Just make up a name if there isn't already an init file set
171 // so we have somewhere to put a new one.
172 if shell.userShellrcPath == "" {
173 shell.userShellrcPath = ".shinit"
174 }
175 default:
176 shell.name = shUnknown
177 }
178 return shell
179}
180
181func WithHistoryFile(historyFile string) ShellOption {
182 return func(s *DevboxShell) {

Callers 4

newShellMethod · 0.85

Calls 2

rcfilePathFunction · 0.85
fishConfigFunction · 0.85