Skip to content
This repository was archived by the owner on May 19, 2022. It is now read-only.

Add an option (deactivated by default) to resolve symlinks. #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ disable fuzzy matching. Default value is 2.
$_FASD_VIMINFO
Path to .viminfo file for viminfo backend, defaults to "$HOME/.viminfo"

$_FASD_RESOLVE_SYMLINKS
Set this option to 1 if you want fasd to resolve symbolic links. This is useful
to prevent duplicates in the entry list. Defaults to 0.

$_FASD_RECENTLY_USED_XBEL
Path to XDG recently-used.xbel file for recently-used backend, defaults to
"$HOME/.local/share/recently-used.xbel"
Expand Down
6 changes: 5 additions & 1 deletion fasd
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fasd() {
[ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native
[ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2
[ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo"
[ -z "$_FASD_RESOLVE_SYMLINKS" ] && _FASD_RESOLVE_SYMLINKS=0
[ -z "$_FASD_RECENTLY_USED_XBEL" ] && \
_FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel"

Expand Down Expand Up @@ -328,10 +329,13 @@ EOS
s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0
s@[^/][^/]*//*\.\./@/@;t 0
s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \
| ( [ $_FASD_RESOLVE_SYMLINKS = 1 ] && xargs -I {} readlink -f {} || cat ) \
| tr '\n' '|')"

# add current pwd if the option is set
[ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD"
local pwd="$PWD"
[ $_FASD_RESOLVE_SYMLINKS = 1 ] && pwd="$(readlink -f "$pwd")"
[ "$_FASD_TRACK_PWD" = 1 -a "$PWD" != "$HOME" ] && paths="$paths|$pwd"

[ -z "${paths##\|}" ] && return # stop if we have nothing to add

Expand Down