Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions commands/dotfiles_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ func pullDotfiles(c *cli.Context) error {

// Initialize all available app handlers
allApps := map[string]model.DotfileApp{
"nvim": model.NewNvimApp(),
"fish": model.NewFishApp(),
"git": model.NewGitApp(),
"zsh": model.NewZshApp(),
"bash": model.NewBashApp(),
"ghostty": model.NewGhosttyApp(),
"claude": model.NewClaudeApp(),
"nvim": model.NewNvimApp(),
"fish": model.NewFishApp(),
"git": model.NewGitApp(),
"zsh": model.NewZshApp(),
"bash": model.NewBashApp(),
"ghostty": model.NewGhosttyApp(),
"claude": model.NewClaudeApp(),
"starship": model.NewStarshipApp(),
}

// Process fetched dotfiles
Expand Down
1 change: 1 addition & 0 deletions commands/dotfiles_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func pushDotfiles(c *cli.Context) error {
model.NewBashApp(),
model.NewGhosttyApp(),
model.NewClaudeApp(),
model.NewStarshipApp(),
}

// Filter apps based on user input
Expand Down
26 changes: 26 additions & 0 deletions model/dotfile_starship.go
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",
}
}
Comment on lines +18 to +22
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for GetConfigPaths only considers the default ~/.config/starship.toml path. Starship configuration is more flexible, respecting the STARSHIP_CONFIG environment variable, and falling back to $XDG_CONFIG_HOME/starship.toml if XDG_CONFIG_HOME is 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.

Suggested change
func (s *StarshipApp) GetConfigPaths() []string {
return []string{
"~/.config/starship.toml",
}
}
func (s *StarshipApp) GetConfigPaths() []string {
// Starship config can be set via STARSHIP_CONFIG env var.
if configPath := os.Getenv("STARSHIP_CONFIG"); configPath != "" {
return []string{configPath}
}
// Default to XDG_CONFIG_HOME if set.
if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" {
return []string{filepath.Join(xdgConfigHome, "starship.toml")}
}
// Fallback to default location.
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The generic CollectFromPaths function has two issues that affect this implementation:

  • It will traverse and collect all files if the config path points to a directory. Starship's config is a single file, so this could lead to unexpected behavior.
  • It stores the absolute, user-specific path (e.g., /home/user/...) instead of the portable path with a tilde (~/.config/...). This breaks synchronization across different machines or users.

A custom CollectDotfiles implementation can address both issues by explicitly checking for files and ensuring the original, portable path is stored.

Note: This change requires adding "os" and "github.com/sirupsen/logrus" to the file's imports.

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
}

Loading