the_silver_searcher
the_silver_searcher copied to clipboard
Support XDG for `.agignore`, like Git does for `.gitignore`
Please support an XDG location for .agignore
like Git does for its .gitignore
.
Benefits
- No need for symlinks when maintaining dotfiles
- No need for an alias
- XDG conformity
Logic
Use first found in this order:
- Check if
"${HOME}/.agignore"
exists - If not, check if
"${XDG_CONFIG_HOME:=$HOME/.config}/ag/ignore"
exists.
Very good idea, everyone is moving away from the root of the home directory, .config
being the desired location.
BTW, did you forget to include the .
on the agignore file? my impression was the only the location is changed, and the filename being the same (with dot)
@ssbarnea Hiding is required only when in user's home folder. Once it's inside .config
, there's no need to hide any more, if it's parent is hidden. Checkout how my ~/.config
directory look like, this is the exact structure, no symlinks.
I'm starting to embrace XDG in my setup and found this issue as a result. What's interesting is that the_silver_searcher
does support XDG_CONFIG_HOME
for looking up gitignore files. ~Two~ Three points I'd like to add:
- In order to support the XDG spec properly, XDG_CONFIG_HOME and each directory in
XDG_CONFIG_DIRS
should be searched. For those familiar with macOS,XDG_CONFIG_HOME
might be set to~/path/to/my/dotfiles
and thenXDG_CONFIG_DIRS
might contain~/Library/Preferences:/Library/Preferences
. - I would propose that the path to look for would be
$XDG_CONFIG_HOME/ag/ignore
. With the file outside of$HOME
and theag
config directory, there's no need for theag-
prefix on the ignore file. - The XDG directories should be searched first and then the old location as a fallback.
In the meantime it's possible to create a workaround for this issue by creating a shell alias that makes use of ag's --path-to-ignore
option
e.g.
alias ag='ag --path-to-ignore $XDG_CONFIG_HOME/ag/ignore'