Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/Publish Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r ./requirements.txt -t ./lib
zip -r Flow.Launcher.Plugin.ZoxidePy.zip . -x '*.git*'
zip -r Flow.Launcher.Plugin.ZoxidePy.zip . -x '*.git*' '*.venv*'
- name: Publish
if: success()
uses: softprops/action-gh-release@v1
Expand Down
19 changes: 15 additions & 4 deletions src/zoxide.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from typing import List

from pyflowlauncher import Result, ResultResponse, send_results
from pyflowlauncher.api import copy_to_clipboard
from pyflowlauncher.icons import COPY, FOLDER, RECYCLEBIN
from pyflowlauncher.api import copy_to_clipboard, open_url
from pyflowlauncher.icons import COPY, FOLDER, RECYCLEBIN, WEB_SEARCH
from src.error import (
ZoxideAddError,
ZoxideNotFound,
ZoxideQueryError,
ZoxideRemoveError,
ZoxideResultParseError,
Expand All @@ -32,7 +31,15 @@ def _get_zoxide_path(self, plugin) -> str:
if os.path.exists(zoxide_path) or shutil.which(zoxide_path) is not None:
return zoxide_path
else:
raise ZoxideNotFound(zoxide_path)
return ""

def _get_zoxide_not_found_result(self) -> Result:
return Result(
Title="Zoxide not found",
SubTitle="Download and install zoxide",
IcoPath=WEB_SEARCH,
JsonRPCAction=open_url("https://github.com/ajeetdsouza/zoxide"),
)

def zoxide_add(self, path: str) -> bool:
cmd = [self.zoxide_path, "add", path.strip()]
Expand Down Expand Up @@ -116,6 +123,8 @@ def generate_context_menu(self, path: str) -> List[Result]:
return results

def cd(self, query: str) -> ResultResponse:
if not self.zoxide_path:
return send_results([self._get_zoxide_not_found_result()])
if not query.strip():
return send_results([])

Expand Down Expand Up @@ -145,6 +154,8 @@ def cd(self, query: str) -> ResultResponse:
)

def open(self, query: str) -> ResultResponse:
if not self.zoxide_path:
return send_results([self._get_zoxide_not_found_result()])
if not query.strip():
return send_results([])

Expand Down