Expose Logo

Expose — Share local sites

Go back to Blog

Open Tinkerwell from your command line with ZSH

Sebastian Schlein

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.

Its time to Tinkerwell

The must-have tinker tool for every PHP and Laravel developer. This magical desktop app may not be able to fly. But when it comes to PHP code, it sure knows how to run.

Learn more