File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 22
22
from collections .abc import Mapping
23
23
from textwrap import dedent
24
24
25
+ import platformdirs
26
+
25
27
from .commands import (
26
28
CommandError ,
27
29
do_connect ,
@@ -439,13 +441,7 @@ def load_user_config():
439
441
config .commands = {}
440
442
441
443
# Get config file name.
442
- path = os .getenv ("XDG_CONFIG_HOME" )
443
- if path is None :
444
- path = os .getenv ("HOME" )
445
- if path is None :
446
- return config
447
- path = os .path .join (path , ".config" )
448
- path = os .path .join (path , _PROG )
444
+ path = platformdirs .user_config_dir (appname = _PROG , appauthor = False )
449
445
config_file = os .path .join (path , "config.py" )
450
446
451
447
# Check if config file exists.
@@ -457,6 +453,9 @@ def load_user_config():
457
453
config_data = f .read ()
458
454
prev_cwd = os .getcwd ()
459
455
os .chdir (path )
456
+ # Pass in the config path so that the config file can use it.
457
+ config .__dict__ ["config_path" ] = path
458
+ config .__dict__ ["__file__" ] = config_file
460
459
exec (config_data , config .__dict__ )
461
460
os .chdir (prev_cwd )
462
461
You can’t perform that action at this time.
0 commit comments