initShellBinaryFields initializes the fields specific to the shell binary that will be used for the devbox shell.
(path string)
| 140 | // initShellBinaryFields initializes the fields specific to the shell binary that will be used |
| 141 | // for the devbox shell. |
| 142 | func 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 | |
| 181 | func WithHistoryFile(historyFile string) ShellOption { |
| 182 | return func(s *DevboxShell) { |