checkpoint: bash profile now fully managed
This commit is contained in:
parent
1e6ca5a9f1
commit
3442f8755f
5 changed files with 73 additions and 3 deletions
|
@ -10,7 +10,7 @@
|
|||
{{ print "" }}
|
||||
### Add {{ $sessionPath.Description }} to PATH
|
||||
if ! [[ "${PATH}" =~ {{ $fullPath }} ]]; then
|
||||
export PATH={{ $fullPath}}:${PATH}
|
||||
export PATH={{ $fullPath}}:${PATH}
|
||||
fi
|
||||
{{- end -}}
|
||||
{{ print "" }}
|
||||
|
|
|
@ -1,15 +1,64 @@
|
|||
{
|
||||
"bashProfile": {
|
||||
"manage": true,
|
||||
"filename": ".bashrc",
|
||||
"sessionPaths": [
|
||||
{
|
||||
"path": ".local/goblin",
|
||||
"description": "the directory of go binaries"
|
||||
"path": ".local/software/element-desktop/bin",
|
||||
"description": "Element"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/firefox/bin",
|
||||
"description": "Firefox"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/go/bin",
|
||||
"description": "Go"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/lua/bin",
|
||||
"description": "Lua"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/lua-language-server/bin",
|
||||
"description": "the Lua Language Server"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/luarocks/bin",
|
||||
"description": "Luarocks"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/neovim/bin",
|
||||
"description": "Neovim"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/node/bin",
|
||||
"description": "Node"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/pulumi/bin",
|
||||
"description": "Pulumi"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/radicle/bin",
|
||||
"description": "Radicle"
|
||||
},
|
||||
{
|
||||
"path": ".local/software/ruby/bin",
|
||||
"description": "Ruby"
|
||||
},
|
||||
{
|
||||
"path": ".local/bin",
|
||||
"description": "the local bin directory"
|
||||
},
|
||||
{
|
||||
"path": "Applications",
|
||||
"description": "the AppImage directory"
|
||||
},
|
||||
{
|
||||
"path": ".local/goblin",
|
||||
"description": "the local gobin directory"
|
||||
},
|
||||
{
|
||||
"path": ".local/scripts",
|
||||
"description": "the directory of custom scripts"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"bashProfile": {
|
||||
"manage": true,
|
||||
"filename": ".bash_profile",
|
||||
"aliases": {},
|
||||
"commands": [
|
||||
{
|
||||
|
|
|
@ -4,6 +4,8 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
|
@ -12,8 +14,14 @@ func BashProfile() error {
|
|||
const (
|
||||
bashProfileTemplateFile string = "bash/profile.gotmpl"
|
||||
managedBashProfile string = "managed/bash_profile"
|
||||
defaultFilename string = ".bash_profile"
|
||||
)
|
||||
|
||||
homeDirectory, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get the user's home configuration directory: %w", err)
|
||||
}
|
||||
|
||||
config, err := newConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load the configuration: %w", err)
|
||||
|
@ -31,5 +39,16 @@ func BashProfile() error {
|
|||
return fmt.Errorf("unable to generate the Bash Profile: %w", err)
|
||||
}
|
||||
|
||||
filename := config.BashProfile.Filename
|
||||
if filename == "" {
|
||||
filename = defaultFilename
|
||||
}
|
||||
|
||||
symlinkPath := filepath.Join(homeDirectory, filename)
|
||||
|
||||
if err := ensureSymlink(managedBashProfile, symlinkPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ type configGitUser struct {
|
|||
|
||||
type configBashProfile struct {
|
||||
Manage bool `json:"manage"`
|
||||
Filename string `json:"filename"`
|
||||
SessionPaths []configBashProfileSessionPath `json:"sessionPaths"`
|
||||
XdgDirectories map[string]string `json:"xdgDirectories"`
|
||||
EnvironmentVariables map[string]string `json:"environmentVariables"`
|
||||
|
|
Loading…
Reference in a new issue