//go:build mage package main import ( "fmt" "text/template" ) // BashProfile manages the user's Bash Profile using their configuration and the Bash Profile template. func BashProfile() error { const ( bashProfileTemplateFile string = "bash/profile.gotmpl" managedBashProfile string = "managed/bash_profile" ) config, err := newConfig() if err != nil { return fmt.Errorf("unable to load the configuration: %w", err) } if !config.BashProfile.Manage { return nil } funcMap := template.FuncMap{ "env": env, } if err := renderTemplate(config, bashProfileTemplateFile, managedBashProfile, funcMap); err != nil { return fmt.Errorf("unable to generate the Bash Profile: %w", err) } return nil }