This post is based around a ZSH function that Fong Hok Kin published in our Tinkerwell Community on GitHub.
Wouldn't it be cool if you could open Tinkerwell directly from your command line by typing tinkerwell .
?
This works by using the Tinkerwell URL schema and using a ZSH function. The easiest way is adding this function to the end of your .zshrc
file:
function tinkerwell {
if [ $# -eq 0 ] || [ $1 = "." ]; then
TW_PATH=$(pwd)
else
TW_PATH=$1
fi
TW_PATH=$(echo -n $TW_PATH | base64)
open "tinkerwell://?cwd=$TW_PATH"
}
As you can see, the function detects if you start it with no parameters or a dot – or if you add a path to it. If no additional parameter is set, the current directory opens in the active tab of Tinkerwell.
# opens current folder
$ tinkerwell
# opens current folder
$ tinkerwell .
# opens "laravel-demo" in current directory
$ tinkerwell laravel-demo
# opens absolute path
$ tinkerwell /Users/sebastian/Code/laravel-demo
At the moment, this uses the active tab of Tinkerwell and connects it to the folder of your command. Future updates of Tinkerwell might be able to open new tabs or include a command line launcher so that you don't need a custom function for your command line anymore.