2
0
mirror of https://github.com/garabik/grc.git synced 2024-09-30 17:51:30 +02:00

Merge pull request #38 from lbschenkel/leonardo

Support the XDG Base Directory Specification
This commit is contained in:
Radovan Garabík 2016-10-17 22:26:39 +02:00 committed by GitHub
commit 26758e85cd
3 changed files with 28 additions and 8 deletions

15
grc
View File

@ -81,10 +81,17 @@ if use_pty:
conffile = None conffile = None
if cfile == "": if cfile == "":
home = [] home = os.environ.get('HOME')
if 'HOME' in os.environ: xdg = os.environ.get('XDG_CONFIG_HOME')
home = [os.environ['HOME']+"/.grc/grc.conf"] if not xdg and home:
conffilenames = home + ["/etc/grc.conf"] 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: for i in conffilenames:
if os.path.isfile(i): if os.path.isfile(i):
conffile = i conffile = i

View File

@ -11,7 +11,7 @@ conf.log
conf.configure conf.configure
# ping command # ping command
(^|[/\w\.]+/)ping6?\s (^|[/\w\.]+/)o?ping6?\s
conf.ping conf.ping
# traceroute command # traceroute command

19
grcat
View File

@ -84,9 +84,22 @@ def get_colour(x):
home = [] home = []
conffile = None conffile = None
if 'HOME' in os.environ: xdg_config = os.environ.get('XDG_CONFIG_HOME')
home = [os.environ['HOME']+"/.grc/"] xdg_data = os.environ.get('XDG_DATA_HOME')
conffilepath = [""] + home + ["/usr/local/share/grc/", "/usr/share/grc/"] 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: if len(sys.argv) != 2:
sys.stderr.write("You are not supposed to call grcat directly, but the usage is: grcat conffile\n") sys.stderr.write("You are not supposed to call grcat directly, but the usage is: grcat conffile\n")
sys.exit(1) sys.exit(1)