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 2222from collections .abc import Mapping
2323from textwrap import dedent
2424
25+ import platformdirs
26+
2527from .commands import (
2628 CommandError ,
2729 do_connect ,
@@ -439,13 +441,7 @@ def load_user_config():
439441 config .commands = {}
440442
441443 # 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 )
449445 config_file = os .path .join (path , "config.py" )
450446
451447 # Check if config file exists.
@@ -457,6 +453,9 @@ def load_user_config():
457453 config_data = f .read ()
458454 prev_cwd = os .getcwd ()
459455 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
460459 exec (config_data , config .__dict__ )
461460 os .chdir (prev_cwd )
462461
You can’t perform that action at this time.
0 commit comments