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

new env _FASD_ADD_MAX for max args to process in --add/--proc #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion fasd
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fasd() {
[ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null
[ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1
[ -z "$_FASD_MAX" ] && _FASD_MAX=2000
[ -z "$_FASD_ADD_MAX" ] && _FASD_ADD_MAX=2000
[ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native
[ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2
[ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo"
Expand Down Expand Up @@ -314,7 +315,14 @@ EOS
*\ $1\ *) return;;
esac

shift; fasd --add "$@" # add all arguments except command
shift # remove command itself

# possibly too many elements:
if [ $# -gt $_FASD_ADD_MAX ]; then
shift $(( $# - _FASD_ADD_MAX ))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I found it surprising that this removed the first N excess arguments rather than the last N arguments. That said, I don't know a better way to do this in POSIX shell that isn't some big nasty loop. (I hit the same problem this PR tries to address. I'm now trying to migrate away from fasd to something else.)

fi

fasd --add "$@"
;;

--add|-A) shift # add entries
Expand Down