Skip to content
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

Support XDG #354

Open
chulkilee opened this issue Oct 18, 2020 · 2 comments
Open

Support XDG #354

chulkilee opened this issue Oct 18, 2020 · 2 comments

Comments

@chulkilee
Copy link

I can achieve XDG Base Directory that by setting KERL_CONFIG and KERL_BASE_DIR - but it would be nice kerl supports it out of box, like git does out-of-box.

Here is untested snippet.

Current:

KERL_BASE_DIR=${KERL_BASE_DIR:="$HOME"/.kerl}
KERL_CONFIG=${KERL_CONFIG:="$HOME"/.kerlrc}

New:

xdg_config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
xdg_data_home="${XDG_DATA_HOME:-$HOME/.local/share}"

if [ -z "$KERL_CONFIG" ]; then
    if [ -f "$xdg_config_home"/kerl/kerlrc ]; then
        KERL_CONFIG="$xdg_config_home"/kerl/kerlrc
    elif [ -n "$HOME" ]; then
        KERL_CONFIG="$HOME"/.kerlrc
    else
        # shellcheck disable=SC2016
        echo 'Error: $HOME is empty or not set.' 1>&2
        exit 1
    fi
fi

if [ -z "$KERL_BASE_DIR" ]; then
    if [ -d "$xdg_data_home"/kerl ]; then
        KERL_BASE_DIR="$xdg_data_home"/kerl
    elif [ -n "$HOME" ]; then
        KERL_BASE_DIR="$HOME"/.kerl
    else
        # shellcheck disable=SC2016
        echo 'Error: $HOME is empty or not set.' 1>&2
        exit 1
    fi
fi
@rjcoelho
Copy link

It should be the default

@jadeallenx
Copy link
Collaborator

I like this idea but I don't have time to work on it right now. I would definitely be interested in a PR to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants