Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support XDG for .agignore, like Git does for .gitignore #1020

Open
rafi opened this issue Nov 25, 2016 · 4 comments · May be fixed by #1450
Open

Support XDG for .agignore, like Git does for .gitignore #1020

rafi opened this issue Nov 25, 2016 · 4 comments · May be fixed by #1450

Comments

@rafi
Copy link

rafi commented Nov 25, 2016

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:

  1. Check if "${HOME}/.agignore" exists
  2. If not, check if "${XDG_CONFIG_HOME:=$HOME/.config}/ag/ignore" exists.
@ssbarnea
Copy link

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)

@rafi
Copy link
Author

rafi commented Dec 20, 2016

@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.

@jxpx777
Copy link

jxpx777 commented Feb 25, 2020

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:

  1. 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 then XDG_CONFIG_DIRS might contain ~/Library/Preferences:/Library/Preferences.
  2. I would propose that the path to look for would be $XDG_CONFIG_HOME/ag/ignore. With the file outside of $HOME and the ag config directory, there's no need for the ag- prefix on the ignore file.
  3. The XDG directories should be searched first and then the old location as a fallback.

aarongable added a commit to aarongable/the_silver_searcher that referenced this issue Jun 16, 2021
@gurpreetatwal
Copy link

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants