Fasd: Respect xdg-base-dir specifications

Created on 26 Jul 2018  ·  5Comments  ·  Source: clvv/fasd

Minor thing, but it would be nice if fasdrc can respect xdg-base-directory specs?
I'm just trying to clear up my home folder :)

Should be only these lines (and maybe the readme/man pages)
https://github.com/clvv/fasd/blob/90b531a5daaa545c74c7d98974b54cbdb92659fc/fasd#L42
https://github.com/clvv/fasd/blob/90b531a5daaa545c74c7d98974b54cbdb92659fc/fasd#L45

Also the recommendation for the init-cache file could be changed in that case.
Below is what I'm using, afaict it works for me, however I haven't really tested the cache part as I have manually set that in the fasdrc anyway. Additionally I'm not sure 100% sure if it should be within the XDG_DATA_DIR

--- /usr/bin/fasd   2016-12-22 09:04:45.000000000 +0100
+++ -   2018-07-26 18:41:08.408295465 +0200
@@ -38,11 +38,18 @@
       case $1 in
         env)
           { # source rc files if present
-          [ -s "/etc/fasdrc" ] && . "/etc/fasdrc"
-          [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc"

           # set default options
-          [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd"
+          [ -s "/etc/fasdrc" ] && . "/etc/fasdrc"
+          CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fasdrc"
+          _FASD_DATA=${_FASD_DATA:-"${XDG_CACHE_HOME:-$HOME/.cache/fasd}/fasd"}
+
+          if [ -e "$CONFIG_FILE" ]; then
+              . "$CONFIG_FILE"
+          else
+              [ -s ${CONFIG_FILE:="$HOME/.fasdrc"} ] && . "$CONFIG_FILE"
+          fi
+
           [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help"
           [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox"
           [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo"

All 5 comments

@ixil Have you implemented this? Any issues?

@WnndGws Sorry for slow reply. Have been at a conference. Yes I have, AFAICT it seems to be working normally. I don't know if it is preferred to have fasdrc in ~/.config/fasd/fasdrc or at ~/.config/fasdrc since it's a single file.

@ixil I would prefer to use $XDG_CONFIG_HOME/fasd/fasdrc, since this is the most used version I would say. Many tools are working like it. Maybe a more strong argument is that this keeps it open for possibly future changes when additional files are added.

Nevertheless is there a PR open for that? I annoys me to have this file in my $HOME directory. ^^

@weilbith I now use whjvenyl 's fork which seems to be maintained and the relevant code is much nicer than what I had originally https://github.com/whjvenyl/fasd/commit/d66113b0743ca4573a278184d92b476c7ba9fddf

@ixil seems to be promising. I reinstalled the AUR fasd-git package and edited the source to this fork.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pearofducks picture pearofducks  ·  7Comments

josephholsten picture josephholsten  ·  15Comments

sypl picture sypl  ·  12Comments

rendybjunior picture rendybjunior  ·  14Comments

rosshadden picture rosshadden  ·  6Comments