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 "" }}
|
{{ print "" }}
|
||||||
### Add {{ $sessionPath.Description }} to PATH
|
### Add {{ $sessionPath.Description }} to PATH
|
||||||
if ! [[ "${PATH}" =~ {{ $fullPath }} ]]; then
|
if ! [[ "${PATH}" =~ {{ $fullPath }} ]]; then
|
||||||
export PATH={{ $fullPath}}:${PATH}
|
export PATH={{ $fullPath}}:${PATH}
|
||||||
fi
|
fi
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ print "" }}
|
{{ print "" }}
|
||||||
|
|
|
@ -1,15 +1,64 @@
|
||||||
{
|
{
|
||||||
"bashProfile": {
|
"bashProfile": {
|
||||||
"manage": true,
|
"manage": true,
|
||||||
|
"filename": ".bashrc",
|
||||||
"sessionPaths": [
|
"sessionPaths": [
|
||||||
{
|
{
|
||||||
"path": ".local/goblin",
|
"path": ".local/software/element-desktop/bin",
|
||||||
"description": "the directory of go binaries"
|
"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",
|
"path": "Applications",
|
||||||
"description": "the AppImage directory"
|
"description": "the AppImage directory"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": ".local/goblin",
|
||||||
|
"description": "the local gobin directory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": ".local/scripts",
|
"path": ".local/scripts",
|
||||||
"description": "the directory of custom scripts"
|
"description": "the directory of custom scripts"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"bashProfile": {
|
"bashProfile": {
|
||||||
"manage": true,
|
"manage": true,
|
||||||
|
"filename": ".bash_profile",
|
||||||
"aliases": {},
|
"aliases": {},
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,8 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,8 +14,14 @@ func BashProfile() error {
|
||||||
const (
|
const (
|
||||||
bashProfileTemplateFile string = "bash/profile.gotmpl"
|
bashProfileTemplateFile string = "bash/profile.gotmpl"
|
||||||
managedBashProfile string = "managed/bash_profile"
|
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()
|
config, err := newConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to load the configuration: %w", err)
|
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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ type configGitUser struct {
|
||||||
|
|
||||||
type configBashProfile struct {
|
type configBashProfile struct {
|
||||||
Manage bool `json:"manage"`
|
Manage bool `json:"manage"`
|
||||||
|
Filename string `json:"filename"`
|
||||||
SessionPaths []configBashProfileSessionPath `json:"sessionPaths"`
|
SessionPaths []configBashProfileSessionPath `json:"sessionPaths"`
|
||||||
XdgDirectories map[string]string `json:"xdgDirectories"`
|
XdgDirectories map[string]string `json:"xdgDirectories"`
|
||||||
EnvironmentVariables map[string]string `json:"environmentVariables"`
|
EnvironmentVariables map[string]string `json:"environmentVariables"`
|
||||||
|
|
Loading…
Reference in a new issue