Skip to content
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
14 changes: 10 additions & 4 deletions bin/qfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ function get_cursor_position(){
echo "$row $col"
}

if [[ -d ~/.qfc/ ]]; then
export PATH=~/.qfc/bin:"${PATH}"
# Determine the absolute path to the QFC script.
if [[ -n "$BASH_VERSION" ]]; then
# Bash doesn’t evaluate $0 the right way when the script is sourced;
# use $BASH_SOURCE instead.
QFC=$(realpath $(dirname ${BASH_SOURCE[0]}))/qfc
else
# In zsh, $0 is consistent between sourcing and script invocation.
QFC=$(realpath $(dirname $0))/qfc
fi

if [[ -n "$ZSH_VERSION" ]]; then
Expand All @@ -38,7 +44,7 @@ if [[ -n "$ZSH_VERSION" ]]; then

# instruct qfc to store the result (completion path) into a temporary file
tmp_file=$(mktemp -t qfc.XXXXXXX)
</dev/tty qfc --search="$word" --stdout="$tmp_file"
</dev/tty "$QFC" --search="$word" --stdout="$tmp_file"
result=$(<$tmp_file)
rm -f $tmp_file

Expand Down Expand Up @@ -86,7 +92,7 @@ elif [[ -n "$BASH" ]]; then
word=${word##* }

tmp_file=$(mktemp -t qfc.XXXXXXX)
</dev/tty qfc --search="$word" --stdout="$tmp_file"
</dev/tty "$QFC" --search="$word" --stdout="$tmp_file"
result=$(<$tmp_file)
rm -f $tmp_file

Expand Down