Skip to content

honor XDG_DATA_HOME on Linux and Mac #258

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

Merged
merged 3 commits into from
Jul 1, 2025
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
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
0.14.1 -
-------------------

- Honour XDG_DATA_HOME for configuration on Linux, MacOS.
[0xmohit]

- UX speed improvements.
[ggozad]

Expand Down
12 changes: 7 additions & 5 deletions docs/app_config.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
### App configuration

The app configuration is stored in a directory specific to your operating system, by default:
The app configuration is stored as JSON in `config.json` in a directory specific to your operating system. By default:

* Linux: `~/.local/share/oterm/config.json`
* macOS: `~/Library/Application Support/oterm/config.json`
* Windows: `C:/Users/<USER>/AppData/Roaming/oterm/config.json`
* Linux: `~/.local/share/oterm`
* macOS: `~/Library/Application Support/oterm`
* Windows: `C:/Users/<USER>/AppData/Roaming/oterm`

On Linux & MacOS we honour the `XDG_DATA_HOME` environment variable. In that case, he directory will be `${XDG_DATA_HOME}/oterm`.

If in doubt you can get the directory where `config.json` can be found by running `oterm --data-dir` or `uvx oterm --data-dir` if you installed oterm using uvx.

Expand Down Expand Up @@ -35,4 +37,4 @@ We strive to have sane default key bindings, but there will always be cases wher

All your chat sessions are stored locally in a sqlite database. You can customize the directory where the database is stored by setting the `OTERM_DATA_DIR` environment variable.

You can find the location of the database by running `oterm --db`.
You can find the location of the database by running `oterm --db`.
9 changes: 7 additions & 2 deletions src/oterm/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import os
import sys
from collections.abc import Callable
from functools import wraps
Expand Down Expand Up @@ -117,8 +118,12 @@ def get_default_data_dir() -> Path:

system_paths = {
"win32": home / "AppData/Roaming/oterm",
"linux": home / ".local/share/oterm",
"darwin": home / "Library/Application Support/oterm",
"linux": Path(os.getenv("XDG_DATA_HOME") or Path(home / ".local/share"))
/ "oterm",
"darwin": Path(
os.getenv("XDG_DATA_HOME") or Path(home / "Library/Application Support")
)
/ "oterm",
}

data_path = system_paths[sys.platform]
Expand Down