Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
Created January 10, 2018 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntrepid8/e62759b6fde57bc4de1efb373669948c to your computer and use it in GitHub Desktop.
Save ntrepid8/e62759b6fde57bc4de1efb373669948c to your computer and use it in GitHub Desktop.
Python script to find a .sublime-project file in the current directory and launch the project in Sublime Text.
#!/usr/bin/env python3
import os
import subprocess
cwd = os.getcwd()
file_list = [f for f in os.listdir(cwd) if f.endswith('.sublime-project')]
fl_len = len(file_list)
if fl_len == 0:
print("sublime-project file not found")
elif fl_len == 1:
print("opening: {}".format(file_list[0]))
subprocess.run(["/usr/bin/subl", "--project", file_list[0]])
else:
print("error: multiple sublime-project files found")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment