diff --git a/bin/qfc.sh b/bin/qfc.sh index b7ce9b8..27caaf8 100755 --- a/bin/qfc.sh +++ b/bin/qfc.sh @@ -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 @@ -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) -