From 14fef233e7030cee95ef1e328475d8dbcdf51c5b Mon Sep 17 00:00:00 2001 From: Alexey Kreshchuk Date: Wed, 8 Jul 2020 16:41:45 +0300 Subject: [PATCH 1/2] allow qfc to be outside ~/.qfc --- bin/qfc.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/qfc.sh b/bin/qfc.sh index f6b361e..8e2ec09 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}" +if [[ -n "${BASH_SOURCE[0]}" ]]; then + QFC_DIR="$(dirname "${BASH_SOURCE[0]}")" +elif [[ -n $ZSH_VERSION ]]; then + echo QFC Dir is ${(%):-%N} + QFC_DIR="$(dirname "${(%):-%N}")" +fi +if [[ -x "$QFC_DIR/qfc" ]]; then + export PATH="$QFC_DIR":"${PATH}" fi if [[ -n "$ZSH_VERSION" ]]; then From 845d8955680895216e6c49f7ba29f5ad691923b8 Mon Sep 17 00:00:00 2001 From: Alexey Kreshchuk Date: Wed, 8 Jul 2020 16:46:51 +0300 Subject: [PATCH 2/2] Switch to alias and add fallback --- bin/qfc.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/qfc.sh b/bin/qfc.sh index 8e2ec09..3632e2a 100755 --- a/bin/qfc.sh +++ b/bin/qfc.sh @@ -20,12 +20,15 @@ function get_cursor_position(){ if [[ -n "${BASH_SOURCE[0]}" ]]; then QFC_DIR="$(dirname "${BASH_SOURCE[0]}")" elif [[ -n $ZSH_VERSION ]]; then - echo QFC Dir is ${(%):-%N} QFC_DIR="$(dirname "${(%):-%N}")" +else + QFC_DIR=~/.qfc/bin fi if [[ -x "$QFC_DIR/qfc" ]]; then - export PATH="$QFC_DIR":"${PATH}" + # export PATH="$QFC_DIR":"${PATH}" + alias qfc="$QFC_DIR/qfc" fi +unset QFC_DIR if [[ -n "$ZSH_VERSION" ]]; then # zshell