Skip to content

Commit

Permalink
Conform to XDG Base Directory Specification
Browse files Browse the repository at this point in the history
  • Loading branch information
jaagr authored and whjvenyl committed May 13, 2017
1 parent 4a0c8b8 commit d66113b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 24 deletions.
28 changes: 24 additions & 4 deletions fasd
Expand Up @@ -37,12 +37,32 @@ fasd() {
while [ "$1" ]; do
case $1 in
env)
{ # source rc files if present
[ -s "/etc/fasdrc" ] && . "/etc/fasdrc"
[ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc"
{ # Load configuration file based on XDG Base Directory Spec.

if [ -s "$XDG_CONFIG_HOME/fasd/config" ]; then
. "$XDG_CONFIG_HOME/fasd/config"
# Fallback for when $XDG_CONFIG_HOME is unset
elif [ -s "$HOME/.config/fasd/config" ]; then
. "$HOME/.config/fasd/config"
elif [ -s "$XDG_CONFIG_DIRS/fasd/config" ]; then
. "$XDG_CONFIG_DIRS/fasd/config"
# Fallback for when $XDG_CONFIG_DIRS is unset
elif [ -s "/etc/xdg/fasd/config" ]; then
. "/etc/xdg/fasd/config"
# Fallback to old rc for backward compatibility
else
[ -s "/etc/fasdrc" ] && . "/etc/fasdrc"
[ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc"
fi

# set default options
[ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd"
if [ -z "$_FASD_DATA" ]; then
if [ -n "$XDG_CACHE_HOME" ]; then
_FASD_DATA="$XDG_CACHE_HOME/fasd"
else
_FASD_DATA="$HOME/.cache/fasd"
fi
fi
[ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help"
[ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox"
[ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo"
Expand Down
38 changes: 26 additions & 12 deletions fasd.1
@@ -1,3 +1,6 @@
.\" Automatically generated by Pandoc 1.15.2.1
.\"
.hy
.TH "FASD" "1" "Jul 16, 2012" "fasd user manual" ""
.SH NAME
.PP
Expand All @@ -6,7 +9,7 @@ fasd \- quick access to files and directories
.PP
fasd [options] [query ...]
.PP
[f|a|s|d|z] [options] [query ...]
f|a|s|d|z (#options) [query ...]
.PP
fasd [\-A|\-D] [paths ...]
.SH OPTIONS
Expand Down Expand Up @@ -227,14 +230,25 @@ viminfo: Vim\[aq]s editing history, useful if you want to define an
alias just for editing things in vim
.PP
You can define your own backend by declaring a function by that name in
your \f[C]\&.fasdrc\f[].
You can set default backend with \f[C]_FASD_BACKENDS\f[] variable in our
\f[C]\&.fasdrc\f[].
.SH TWEAKS
your configuration file (#configuration).
You can set default backend with \f[C]_FASD_BACKENDS\f[] variable.
.SH CONFIGURATION
.PP
Upon every execution, fasd will source "/etc/fasdrc" and "$HOME/.fasdrc"
if they are present.
Below are some variables you can set:
Upon every execution, fasd will look for a configuration file in the
following order:
.IP "1." 3
\f[C]$XDG_CONFIG_HOME/fasd/config\f[]
.IP "2." 3
\f[C]$HOME/.config/fasd/config\f[]
.IP "3." 3
\f[C]$XDG_CONFIG_DIRS/fasd/config\f[]
.IP "4." 3
\f[C]/etc/xdg/fasd/config\f[]
.IP "5." 3
\f[C]/etc/fasdrc\f[] and \f[C]$HOME/.fasdrc\f[] (for backward
compatibility)
.PP
Below are the available variables you can set:
.IP
.nf
\f[C]
Expand Down Expand Up @@ -295,12 +309,12 @@ If fasd does not work as expected, please file a bug report on GitHub
describing the unexpected behavior along with your OS version, shell
version, awk version, sed version, and a log file.
.PP
You can set \f[C]_FASD_SINK\f[] in your \f[C]\&.fasdrc\f[] to obtain a
log.
You can set \f[C]_FASD_SINK\f[] in your configuration
file (#configuration) to obtain a log.
.IP
.nf
\f[C]
_FASD_SINK="$HOME/.fasd.log"
_FASD_SINK="$HOME/fasd.log"
\f[]
.fi
.SH COPYING
Expand All @@ -310,4 +324,4 @@ Fasd is originally written based on code from z
Most if not all of the code has been rewritten.
Fasd is licensed under the "MIT/X11" license.
.SH AUTHORS
Wei Dai <x@wei23.net>.
Wei Dai <x@wei23.net> and contributors.
24 changes: 16 additions & 8 deletions fasd.1.md
@@ -1,5 +1,5 @@
% FASD(1) fasd user manual
% Wei Dai <x@wei23.net>
% Wei Dai <x@wei23.net> and contributors
% Jul 16, 2012

# NAME
Expand Down Expand Up @@ -187,13 +187,21 @@ backends.
for editing things in vim

You can define your own backend by declaring a function by that name in your
`.fasdrc`. You can set default backend with `_FASD_BACKENDS` variable in our
`.fasdrc`.
[configuration file](#configuration). You can set default backend with `_FASD_BACKENDS` variable.

# TWEAKS

Upon every execution, fasd will source "/etc/fasdrc" and "$HOME/.fasdrc" if
they are present. Below are some variables you can set:
# CONFIGURATION

Upon every execution, fasd will look for a configuration file in the following
order:

1. `$XDG_CONFIG_HOME/fasd/config`
2. `$HOME/.config/fasd/config`
3. `$XDG_CONFIG_DIRS/fasd/config`
4. `/etc/xdg/fasd/config`
5. `/etc/fasdrc` and `$HOME/.fasdrc` (for backward compatibility)

Below are the available variables you can set:

$_FASD_DATA
Path to the fasd data file, default "$HOME/.fasd".
Expand Down Expand Up @@ -251,9 +259,9 @@ If fasd does not work as expected, please file a bug report on GitHub describing
the unexpected behavior along with your OS version, shell version, awk version,
sed version, and a log file.

You can set `_FASD_SINK` in your `.fasdrc` to obtain a log.
You can set `_FASD_SINK` in your [configuration file](#configuration) to obtain a log.

_FASD_SINK="$HOME/.fasd.log"
_FASD_SINK="$HOME/fasd.log"

# COPYING

Expand Down

0 comments on commit d66113b

Please sign in to comment.