Skip to content

Commit 9f101cd

Browse files
committed
Allow to source configuration files from common directories
Now custom configuration files are sourced from the following directories (in that order): - /etc/gdb-dashboard/ - $XDG_CONFIG_HOME/gdb-dashboard/ (or ~/.config/gdb-dashboard/) - ~/Library/Preferences/gdb-dashboard/ - ~/.gdbinit.d/ This provides a better implementation of and closes #238.
1 parent 3b4582a commit 9f101cd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.gdbinit

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ python
2929
# Imports ----------------------------------------------------------------------
3030

3131
import ast
32+
import itertools
3233
import math
3334
import os
3435
import re
@@ -625,7 +626,17 @@ class Dashboard(gdb.Command):
625626

626627
@staticmethod
627628
def parse_inits(python):
628-
for root, dirs, files in os.walk(os.path.expanduser('~/.gdbinit.d/')):
629+
# paths where the .gdbinit.d directory might be
630+
search_paths = [
631+
'/etc/gdb-dashboard',
632+
'{}/gdb-dashboard'.format(os.getenv('XDG_CONFIG_HOME', '~/.config')),
633+
'~/Library/Preferences/gdb-dashboard',
634+
'~/.gdbinit.d'
635+
]
636+
# expand the tilde and walk the paths
637+
inits_dirs = (os.walk(os.path.expanduser(path)) for path in search_paths)
638+
# process all the init files in order
639+
for root, dirs, files in itertools.chain.from_iterable(inits_dirs):
629640
dirs.sort()
630641
for init in sorted(files):
631642
path = os.path.join(root, init)

0 commit comments

Comments
 (0)