the_silver_searcher icon indicating copy to clipboard operation
the_silver_searcher copied to clipboard

Support XDG for `.agignore`, like Git does for `.gitignore`

Open rafi opened this issue 8 years ago • 4 comments

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.

rafi avatar Nov 25 '16 12:11 rafi

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 avatar Dec 20 '16 13:12 ssbarnea

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

rafi avatar Dec 20 '16 14:12 rafi

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.

jxpx777 avatar Feb 25 '20 18:02 jxpx777

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'

gurpreetatwal avatar Jul 12 '21 20:07 gurpreetatwal