Skip to content

Support ~/.config/treemd as primary config path on macOS #41

@petamorikei

Description

@petamorikei

Summary

On macOS, treemd only reads config from ~/Library/Application Support/treemd/config.toml. It would be more convenient to prioritize ~/.config/treemd/config.toml instead.

Current Behavior

The Config::config_path() function uses dirs::config_dir(), which returns:

  • Linux: ~/.config
  • macOS: ~/Library/Application Support
  • Windows: %APPDATA%

This means ~/.config/treemd/config.toml is not recognized on macOS.

Proposed Behavior

On macOS, check both paths with the following priority:

  1. ~/.config/treemd/config.toml (primary)
  2. ~/Library/Application Support/treemd/config.toml (fallback)

Motivation

  • Many CLI tools and developer-focused applications support ~/.config on macOS
  • Easier dotfiles management with a unified ~/.config directory
  • Simpler to sync configs across Linux and macOS environments
  • Users who prefer the Apple-standard path can still use it as a fallback

Possible Implementation

In src/config.rs, modify the Config::load() method:

pub fn load() -> Self {
    #[cfg(target_os = "macos")]
    {
        // Prefer XDG-style path on macOS
        if let Some(home) = dirs::home_dir() {
            let xdg_path = home.join(".config/treemd/config.toml");
            if let Some(config) = Self::load_from_path(&xdg_path) {
                return config;
            }
        }
    }
    // Fall back to platform-specific path
    if let Some(config) = Self::config_path().and_then(|p| Self::load_from_path(&p)) {
        return config;
    }
    Self::default()
}

This approach:

  • Prioritizes ~/.config for users who prefer XDG-style paths
  • Falls back to ~/Library/Application Support for existing users
  • No change for Linux/Windows users

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions