From 0bf0473b90a2048d39e3aad3c848283c69ee5666 Mon Sep 17 00:00:00 2001 From: rlfx Date: Tue, 7 Feb 2023 17:44:19 +0100 Subject: [PATCH 1/2] Fix git path being hard-coded This enables running hyfetch on machines without git installed via the git-for-windows installer. --- hyfetch/neofetch_util.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hyfetch/neofetch_util.py b/hyfetch/neofetch_util.py index 1046297c..66094acb 100644 --- a/hyfetch/neofetch_util.py +++ b/hyfetch/neofetch_util.py @@ -7,6 +7,7 @@ import shlex import subprocess import sys import zipfile +import shutil from dataclasses import dataclass from pathlib import Path from subprocess import check_output @@ -150,7 +151,6 @@ def get_command_path() -> str: return cmd_path - def ensure_git_bash() -> Path: """ Ensure git bash installation for windows @@ -163,6 +163,17 @@ def ensure_git_bash() -> Path: if def_path.is_file(): return def_path + # Labda expression that finds out if a command exists + cmd_exists = lambda x: shutil.which(x) is not None + + # TEMP-FIX: Make git not hard-coded to being installed "officially" via the git-for-windows installer + if ( cmd_exists("git.exe") ): + pth = Path(shutil.which("git")).parent + if(os.path.isfile(pth / r'bash.exe')): + return pth / r'bash.exe' + elif ( os.path.isfile(pth / r'/bin/bash.exe')): + return pth / r'/bin/bash.exe' + # Find installation in PATH (C:\Program Files\Git\cmd should be in path) pth = (os.environ.get('PATH') or '').lower().split(';') pth = [p for p in pth if p.endswith(r'\git\cmd')] From 026cfffde1364df8ddab9c6390ad96dc3e95e683 Mon Sep 17 00:00:00 2001 From: rlfx Date: Tue, 7 Feb 2023 19:13:37 +0100 Subject: [PATCH 2/2] add vscode debugger profile, It's why my copy didn't work. --- .vscode/launch.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..260f05c2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Module", + "type": "python", + "request": "launch", + "module": "hyfetch", + "justMyCode": true + } + ] +} \ No newline at end of file