mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-19 20:48:31 +02:00
Support JRNLRC environment variable to specify configuration file
This allows switching configurations using e.g. direnv.
This commit is contained in:
parent
81dfebb2c0
commit
e6a819bda9
2 changed files with 5 additions and 1 deletions
|
@ -8,6 +8,8 @@ Configuration File
|
|||
|
||||
You can configure the way jrnl behaves in a configuration file. By default, this is ``~/.jrnl_config``. If you have the ``XDG_CONFIG_HOME`` variable set, the configuration file will be saved under ``$XDG_CONFIG_HOME/jrnl``.
|
||||
|
||||
The default path can be overridden with the ``JRNLRC`` environment variable. This can be useful if you want to keep project specific configurations and automatically switch to them using e.g. ``direnv``.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, The configuration file is typically found at ``C:\Users\[Your Username]\.jrnl_config``.
|
||||
|
|
|
@ -19,10 +19,12 @@ DEFAULT_CONFIG_NAME = 'jrnl.yaml'
|
|||
DEFAULT_JOURNAL_NAME = 'journal.txt'
|
||||
XDG_RESOURCE = 'jrnl'
|
||||
|
||||
ENV_JRNLRC = os.environ.get('JRNLRC')
|
||||
|
||||
USER_HOME = os.path.expanduser('~')
|
||||
|
||||
CONFIG_PATH = xdg.BaseDirectory.save_config_path(XDG_RESOURCE) or USER_HOME
|
||||
CONFIG_FILE_PATH = os.path.join(CONFIG_PATH, DEFAULT_CONFIG_NAME)
|
||||
CONFIG_FILE_PATH = ENV_JRNLRC or os.path.join(CONFIG_PATH, DEFAULT_CONFIG_NAME)
|
||||
CONFIG_FILE_PATH_FALLBACK = os.path.join(USER_HOME, ".jrnl_config")
|
||||
|
||||
JOURNAL_PATH = xdg.BaseDirectory.save_data_path(XDG_RESOURCE) or USER_HOME
|
||||
|
|
Loading…
Add table
Reference in a new issue