Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

**Bugfix** **Enhanced** on Windows 11 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
35 changes: 20 additions & 15 deletions openingithub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
from subprocess import Popen
import platform
from fman import DirectoryPaneCommand, show_alert, load_json
import shutil
import subprocess
from fman import DirectoryPaneCommand, show_alert

PLUGIN_SETTINGS = load_json("OpenInGithub Settings.json")[0]
GITHUB_BINARY = PLUGIN_SETTINGS["github_binary"]

class OpenInGithub(DirectoryPaneCommand):
def __call__(self):
file_under_cursor = self.pane.get_file_under_cursor()
if file_under_cursor:
if platform.system() == "Windows":
Popen('"%s" %s' % (GITHUB_BINARY, file_under_cursor), shell=True)
else:
Popen('%s "%s"' % (GITHUB_BINARY, file_under_cursor), shell=True)
GITHUB_PATH = shutil.which("github")

if GITHUB_PATH is None:
raise ValueError("Github command-line tool not found in PATH. Please install Github or add it to your PATH.")

else:
show_alert("No file selected.")
class OpenInGithub(DirectoryPaneCommand):
def __call__(self):
file_under_cursor_unf = self.pane.get_file_under_cursor()
file_under_cursor = file_under_cursor_unf if not file_under_cursor_unf.startswith("file://") else file_under_cursor_unf[7:]

if not file_under_cursor:
show_alert("No file selected.")
return
try:
subprocess.run([GITHUB_PATH, file_under_cursor], shell=True)

except subprocess.CalledProcessError:
show_alert("Failed to open file in Github.")