-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add starship config support to dotfiles push/pull #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package model | ||
|
|
||
| import "context" | ||
|
|
||
| // StarshipApp handles Starship configuration files | ||
| type StarshipApp struct { | ||
| BaseApp | ||
| } | ||
|
|
||
| func NewStarshipApp() DotfileApp { | ||
| return &StarshipApp{} | ||
| } | ||
|
|
||
| func (s *StarshipApp) Name() string { | ||
| return "starship" | ||
| } | ||
|
|
||
| func (s *StarshipApp) GetConfigPaths() []string { | ||
| return []string{ | ||
| "~/.config/starship.toml", | ||
| } | ||
| } | ||
|
|
||
| func (s *StarshipApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) { | ||
| return s.CollectFromPaths(ctx, s.Name(), s.GetConfigPaths()) | ||
| } | ||
|
Comment on lines
+24
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The generic
A custom Note: This change requires adding func (s *StarshipApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) {
hostname, _ := os.Hostname()
var dotfiles []DotfileItem
for _, path := range s.GetConfigPaths() {
expandedPath, err := s.expandPath(path)
if err != nil {
logrus.Debugf("Failed to expand path %s: %v", path, err)
continue
}
fileInfo, err := os.Stat(expandedPath)
if err != nil {
if !os.IsNotExist(err) {
logrus.Debugf("Failed to stat path %s: %v", expandedPath, err)
}
continue
}
if fileInfo.IsDir() {
logrus.Warnf("Starship config path is a directory, but should be a file: %s", expandedPath)
continue
}
content, modTime, err := s.readFileContent(path)
if err != nil {
logrus.Debugf("Failed to read file content for %s: %v", path, err)
continue
}
dotfiles = append(dotfiles, DotfileItem{
App: s.Name(),
Path: path, // Use original path to preserve '~'
Content: content,
FileModifiedAt: modTime,
FileType: "file",
Hostname: hostname,
})
}
return dotfiles, nil
} |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation for
GetConfigPathsonly considers the default~/.config/starship.tomlpath. Starship configuration is more flexible, respecting theSTARSHIP_CONFIGenvironment variable, and falling back to$XDG_CONFIG_HOME/starship.tomlifXDG_CONFIG_HOMEis set. To make this more robust and align with starship's behavior, consider checking for these environment variables.This will require adding
"os"and"path/filepath"to your imports.