Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Automate egghead Lesson Setup with ZSH Shell Functions

    John LindquistJohn Lindquist
    eggheadegghead

    Sometimes you have an idea that you want to quickly record, but the idea of setting up a project just to get it recorded gets in your way. I'm going to walk your through scripting away the main setup pain points so that you can focus on creating content.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    John Lindquist: From my terminal, I can write +vanilla. The name of my lesson is awesome-lesson-idea. I'll enter.

    Then it will clone and install everything I need, create a GitHub project with everything pushed up there, and setup an invoke parcel and code, so that it launches code to an index.js. On my other monitor, it opened this window, which is running whatever I type into this file.

    If I console.logout("hello"), it's saved there. You can see "hello" in this file. Also, if I go to GitHub and show my repos, you can see that awesome-lesson-idea is already up here with everything that was installed. My script for this looks something like stop this and open my zsh file. I say change directories into projects.

    There's a tool called degit which will take a template, remove all the git stuff, so you're not working on a fork. It's a clean version of the project. It will name it whatever you passed in that name. It will cd into that name. Set up all the necessary git stuff. Git create is from hub.github.com. This will add the ability to automatically create projects from your command line. Then it'll push it.

    PNPM is a way of NPM installing packages which are locally cached in your computer. Then you can use code in the current directory with the -g flag to launch a specific file. Then my template has a start script. For this all to work, you do need to install degit which is just an NPM package, NPM degit. Go ahead and install this.

    Make sure you install Hub so you can use the git create command. If you're using code, that should be obvious there. I'll just paste this at the bottom of the lesson, so that'll be there for you. Then once I'm done with this lesson, back in my terminal, I can type +egghead, hit enter. This will commit and push all the files up to my repo.

    It will launch the embedded version of the code Sandbox. This is the exact project and all of its files loaded from GitHub. Then it also launches Chrome to the new lesson uploader.

    What that looks like is in my zshrc, git add, git commit. I'm just parsing in the date, so my commit will have the date in there. Get push, and then telling Chrome to open that CodeSandbox, which is linked to the repo, based on my directory name, and then my user account. Then it just also opens the URL to upload Egghead lessons.