1- //go:generate go-bindata -o init.go init/
2-
31package main
42
53import (
4+ _ "embed"
65 "encoding/json"
76 "flag"
87 "fmt"
@@ -14,6 +13,18 @@ import (
1413// Version number of oh-my-posh
1514var Version = "development"
1615
16+ //go:embed init/omp.ps1
17+ var pwshInit string
18+
19+ //go:embed init/omp.fish
20+ var fishInit string
21+
22+ //go:embed init/omp.bash
23+ var bashInit string
24+
25+ //go:embed init/omp.zsh
26+ var zshInit string
27+
1728const (
1829 noExe = "echo \" Unable to find Oh my Posh executable\" "
1930 zsh = "zsh"
@@ -185,25 +196,20 @@ func printShellInit(shell, config string) string {
185196 }
186197 switch shell {
187198 case pwsh :
188- return getShellInitScript (executable , config , "init/omp.ps1" )
199+ return getShellInitScript (executable , config , pwshInit )
189200 case zsh :
190- return getShellInitScript (executable , config , "init/omp.zsh" )
201+ return getShellInitScript (executable , config , zshInit )
191202 case bash :
192- return getShellInitScript (executable , config , "init/omp.bash" )
203+ return getShellInitScript (executable , config , bashInit )
193204 case fish :
194- return getShellInitScript (executable , config , "init/omp.fish" )
205+ return getShellInitScript (executable , config , fishInit )
195206 default :
196207 return fmt .Sprintf ("echo \" No initialization script available for %s\" " , shell )
197208 }
198209}
199210
200211func getShellInitScript (executable , config , script string ) string {
201- data , err := Asset (script )
202- if err != nil {
203- return fmt .Sprintf ("echo \" Unable to find initialization script %s\" " , script )
204- }
205- init := string (data )
206- init = strings .ReplaceAll (init , "::OMP::" , executable )
207- init = strings .ReplaceAll (init , "::CONFIG::" , config )
208- return init
212+ script = strings .ReplaceAll (script , "::OMP::" , executable )
213+ script = strings .ReplaceAll (script , "::CONFIG::" , config )
214+ return script
209215}
0 commit comments