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

Adds option _FASD_NOCASE to force default matching to ignore case #104

Open
wants to merge 4 commits 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ $_FASD_RECENTLY_USED_XBEL
Path to XDG recently-used.xbel file for recently-used backend, defaults to
"$HOME/.local/share/recently-used.xbel"

$_FASD_NOCASE
Force case insensitivity for default matching with value 1, defaults to 0.
```

# Debugging
Expand Down
7 changes: 5 additions & 2 deletions fasd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fasd() {
[ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo"
[ -z "$_FASD_RECENTLY_USED_XBEL" ] && \
_FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel"
[ -z "$_FASD_NOCASE" ] && _FASD_NOCASE=0

if [ -z "$_FASD_AWK" ]; then
# awk preferences
Expand Down Expand Up @@ -416,17 +417,19 @@ $(fasd --backend $each)"
*) local prior='times[i] * frecent(la[i])';;
esac

if [ "$fnd" ]; then # dafault matching
if [ "$fnd" ]; then # default matching
local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g
s@ @[^|]*@g;s/\$$/|/')"
bre='^[^|]*'"$bre"'[^|/]*|'
local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")"
# force no case matching for default matching
[ "$_FASD_NOCASE" = 1 ] && _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")"
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
done)"
if [ "$_ret" ]; then
_fasd_data="$_ret"
else # no case mathcing
else # no case matching
_ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")"
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
Expand Down
3 changes: 3 additions & 0 deletions fasd.1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ Path\ to\ .viminfo\ file\ for\ viminfo\ backend,\ defaults\ to\ "$HOME/.viminfo"
$_FASD_RECENTLY_USED_XBEL
Path\ to\ XDG\ recently\-used.xbel\ file\ for\ recently\-used\ backend,\ defaults\ to
"$HOME/.local/share/recently\-used.xbel"

$_FASD_NOCASE
Force\ case\ insensitivity\ for\ default\ matching\ with\ value\ 1,\ defaults\ to \0.
\f[]
.fi
.SH DEBUGGING
Expand Down
4 changes: 4 additions & 0 deletions fasd.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ they are present. Below are some variables you can set:
Path to XDG recently-used.xbel file for recently-used backend, defaults to
"$HOME/.local/share/recently-used.xbel"

$_FASD_NOCASE
Force case insensitivity for default matching with value 1, defaults to 0.


# DEBUGGING

Fasd is hosted on GitHub: https://github.com/clvv/fasd
Expand Down