Last active
March 21, 2024 18:30
-
-
Save mpociot/ae7f4711ff4804d7ffab6a6aac4730c7 to your computer and use it in GitHub Desktop.
Python script to open Tinkerwell from your current working directory - tinkerwell.app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
RUN_PATH = '/Applications/Tinkerwell.app' | |
def process_args(argv): | |
args = [] | |
for i, arg in enumerate(argv[1:]): | |
path = arg | |
args.append('-path') | |
args.append(os.path.abspath(path)) | |
return args | |
def start_new_instance(args): | |
if len(args) > 0: | |
args.insert(0, '--args') | |
os.execvp('/usr/bin/open', ['-a', RUN_PATH] + args) | |
tinker_args = process_args(sys.argv) | |
start_new_instance(tinker_args) |
@niladam you can add a -n
flag to open it in a new window. that's what I'm using in the Tinkerwell Alfred extension
Eg.
open -a tinkerwell -n --args -path $1
@chrisrenga whoa, that's awesome! Thank you for that!:)
#!/bin/bash
if [[ $# -eq 0 ]] ; then
PATH=$(pwd)
elif [ $1 = "." ]; then
PATH=$(pwd)
else
HEAD=$(dirname "$1")
HEAD=$(cd "$HEAD" && pwd)
PATH="$HEAD/$(basename $1)"
fi
PATH=$(echo $PATH | /usr/bin/base64)
/usr/bin/open "tinkerwell://?cwd=$PATH"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be great if multiple windows could be used or if tabs would work.. :) -- maybe add this in the 1.2 release @mpociot ?:)