@@ -53,6 +53,8 @@ diverged = "<>"
5353renamed = "r"
5454deleted = "x"
5555`
56+
57+ fishVersion = "4.0b1"
5658)
5759
5860func (g * generalGraph ) compileShell (root llb.State ) (_ llb.State , err error ) {
@@ -63,6 +65,9 @@ func (g *generalGraph) compileShell(root llb.State) (_ llb.State, err error) {
6365 if err != nil {
6466 return llb.State {}, err
6567 }
68+ } else if g .Shell == shellFish {
69+ g .RuntimeEnviron ["SHELL" ] = "/usr/bin/fish"
70+ root = g .compileFish (root )
6671 }
6772 if g .CondaConfig != nil {
6873 root = g .compileCondaShell (root )
@@ -76,13 +81,17 @@ func (g *generalGraph) compileCondaShell(root llb.State) llb.State {
7681 findDir = fileutil .EnvdHomeDir
7782 }
7883 rcPath := findDir (".bashrc" )
84+ activateFile := "activate"
7985 if g .Shell == shellZSH {
8086 rcPath = findDir (".zshrc" )
87+ } else if g .Shell == shellFish {
88+ rcPath = findDir (".config/fish/config.fish" )
89+ activateFile = "activate.fish"
8190 }
8291 run := root .
8392 Run (llb .Shlexf ("bash -c \" %s\" " , g .condaInitShell (g .Shell )),
8493 llb .WithCustomNamef ("[internal] init conda %s env" , g .Shell )).
85- Run (llb .Shlexf (`bash -c 'echo "source %s/activate envd" >> %s'` , condaBinDir , rcPath ),
94+ Run (llb .Shlexf (`bash -c 'echo "source %s/%s envd" >> %s'` , condaBinDir , activateFile , rcPath ),
8695 llb .WithCustomNamef ("[internal] add conda environment to %s" , rcPath ))
8796 return run .Root ()
8897}
@@ -102,6 +111,10 @@ func (g *generalGraph) compilePrompt(root llb.State) llb.State {
102111 run = run .Run (
103112 llb .Shlexf (`bash -c 'echo "eval \"\$(starship init zsh)\"" >> %s'` , fileutil .EnvdHomeDir (".zshrc" )),
104113 llb .WithCustomName ("[internal] setting prompt zsh config" )).Root ()
114+ } else if g .Shell == shellFish {
115+ run = run .Run (
116+ llb .Shlexf (`bash -c 'echo "starship init fish | source" >> %s'` , fileutil .EnvdHomeDir (".config/fish/config.fish" )),
117+ llb .WithCustomName ("[internal] setting prompt fish config" )).Root ()
105118 }
106119 return run
107120}
@@ -126,3 +139,18 @@ func (g generalGraph) compileZSH(root llb.State) (llb.State, error) {
126139 File (llb .Mkfile (zshrcPath , 0666 , []byte (m .ZSHRC ())))
127140 return zshrc , nil
128141}
142+
143+ func (g generalGraph ) compileFish (root llb.State ) llb.State {
144+ base := llb .Image (builderImage )
145+ builder := base .Run (
146+ llb .Shlexf (`sh -c "wget -qO- https://github.com/fish-shell/fish-shell/releases/download/%s/fish-static-linux-$(uname -m).tar.xz | tar -xJf - -C /tmp || exit 1"` , fishVersion ),
147+ llb .WithCustomName ("[internal] download fish shell" ),
148+ ).Root ()
149+ root = root .File (
150+ llb .Copy (builder , "/tmp/fish" , "/usr/bin/fish" ),
151+ llb .WithCustomName ("[internal] copy fish shell from the builder image" )).
152+ Run (llb .Shlex ("fish --install" ),
153+ llb .WithCustomName ("[internal] install fish shell" )).Root ()
154+
155+ return root
156+ }
0 commit comments