Demand
This is often the case when writing code that requires experimental ideas and a playground environment to play. If it's a front-end, you can open Chrome's console, but if it's node, it's a bit of a hassle. I want to open my directory to store the test code, create a new directory, create a JS file, open the editor to start writing code. This series of troublesome processes leads directly to the deterioration of my quality of life. It would be nice if we could automate the process. What I want is to hit a command at the terminal and then help me to do all of these things, and then the ready-made editor in front of me, directly to start tapping the code.
Scheme
With homemade tools: Upload modified files to a specific server experience, now I just need to write a bash script that helps me:
- Accept a name that I want to specify and create the appropriate playground directory.
- Open my favorite editor and create a JS file with the name I specify.
- Open the terminal in the newly created playground directory to run debugging.
mkdir $1"$1/$1.js" && open-a terminal/users/drakedan/ documents/workspace/nodeplayground/$1
Save the above code in the directory where I specifically store the gadget, named Playnode.sh.
If you don't have a directory dedicated to gadgets, you can create one and then open ~/.bash_profile with the editor and add a single line to the list:
Export Path=${path}:/users/drakedan/documents/workspace/nodeplayground/bin
Here all my gadgets are placed in the /users/drakedan/documents/workspace/nodeplayground/bin directory.
Summarize
Finally only need to restart the terminal, and then only use in the terminal knocking >playnode.sh myplay gadget will help me to create a myplay directory under the specified directory, and sublime Open Myplay.js, and also thoughtful for me to open a terminal located in the Myplay directory. I'm done, and my mother doesn't have to worry about my delaying cancer any more!
Reference: Homemade tools: Uploading modified files to a specified server
Open Terminal here in Mac Os Finder
Self-made tool: quickly open a node environment playground