mirror of
https://github.com/garabik/grc.git
synced 2024-11-15 14:48:26 +01:00
Merge pull request #38 from lbschenkel/leonardo
Support the XDG Base Directory Specification
This commit is contained in:
commit
26758e85cd
3 changed files with 28 additions and 8 deletions
15
grc
15
grc
|
@ -81,10 +81,17 @@ if use_pty:
|
|||
|
||||
conffile = None
|
||||
if cfile == "":
|
||||
home = []
|
||||
if 'HOME' in os.environ:
|
||||
home = [os.environ['HOME']+"/.grc/grc.conf"]
|
||||
conffilenames = home + ["/etc/grc.conf"]
|
||||
home = os.environ.get('HOME')
|
||||
xdg = os.environ.get('XDG_CONFIG_HOME')
|
||||
if not xdg and home:
|
||||
xdg = home + '/.config'
|
||||
|
||||
conffilenames = []
|
||||
if xdg:
|
||||
conffilenames += [xdg + '/grc/grc.conf']
|
||||
if home:
|
||||
conffilenames += [home + '/.grc/grc.conf']
|
||||
conffilenames += ['/usr/local/etc/grc.conf', '/etc/grc.conf']
|
||||
for i in conffilenames:
|
||||
if os.path.isfile(i):
|
||||
conffile = i
|
||||
|
|
2
grc.conf
2
grc.conf
|
@ -11,7 +11,7 @@ conf.log
|
|||
conf.configure
|
||||
|
||||
# ping command
|
||||
(^|[/\w\.]+/)ping6?\s
|
||||
(^|[/\w\.]+/)o?ping6?\s
|
||||
conf.ping
|
||||
|
||||
# traceroute command
|
||||
|
|
19
grcat
19
grcat
|
@ -84,9 +84,22 @@ def get_colour(x):
|
|||
|
||||
home = []
|
||||
conffile = None
|
||||
if 'HOME' in os.environ:
|
||||
home = [os.environ['HOME']+"/.grc/"]
|
||||
conffilepath = [""] + home + ["/usr/local/share/grc/", "/usr/share/grc/"]
|
||||
xdg_config = os.environ.get('XDG_CONFIG_HOME')
|
||||
xdg_data = os.environ.get('XDG_DATA_HOME')
|
||||
home = os.environ.get('HOME')
|
||||
if home and not xdg_config:
|
||||
xdg_config = home + '/.config'
|
||||
if home and not xdg_data:
|
||||
xdg_data = home + '/.local/share'
|
||||
|
||||
conffilepath = [""]
|
||||
if xdg_data:
|
||||
conffilepath += [xdg_data + '/grc/']
|
||||
if xdg_config:
|
||||
conffilepath += [xdg_config + '/grc/']
|
||||
if home:
|
||||
conffilepath += [home + '/.grc/']
|
||||
conffilepath += ['/usr/local/share/grc/', '/usr/share/grc/']
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("You are not supposed to call grcat directly, but the usage is: grcat conffile\n")
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Reference in a new issue