How I Setup a New Development Machine - Using Scripts to Automate Installs and Save Time
28:20

How I Setup a New Development Machine - Using Scripts to Automate Installs and Save Time

Corey Schafer 15.04.2019 60 262 просмотров 1 316 лайков

Machine-readable: Markdown · JSON API · Site index

Поделиться Telegram VK Бот
Транскрипт Скачать .md
Анализ с AI
Описание видео
In this video, I'll be showing how I set up a new development machine. I recently got a new MacBook and wanted to show how I use scripts to automate a lot of this process. It used to take me a lot of time to install all of my software and get everything set up the way I like it. Now I use these automated scripts to do this in minutes. Let's get started... My Dotfiles - https://github.com/CoreyMSchafer/dotfiles Homebrew Tutorial - https://youtu.be/SELYgZvAZbU Dotfiles Tutorial - https://youtu.be/c5RZWDLqifA ✅ Support My Channel Through Patreon: https://www.patreon.com/coreyms ✅ Become a Channel Member: https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join ✅ One-Time Contribution Through PayPal: https://goo.gl/649HFY ✅ Cryptocurrency Donations: Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3 Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33 Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot ✅ Corey's Public Amazon Wishlist http://a.co/inIyro1 ✅ Equipment I Use and Books I Recommend: https://www.amazon.com/shop/coreyschafer ▶️ You Can Find Me On: My Website - http://coreyms.com/ My Second Channel - https://www.youtube.com/c/coreymschafer Facebook - https://www.facebook.com/CoreyMSchafer Twitter - https://twitter.com/CoreyMSchafer Instagram - https://www.instagram.com/coreymschafer/ #MacBook #MacBookPro

Оглавление (12 сегментов)

Intro

hey there how's it going everybody in this video I'm gonna show you how I set up a new development machine from scratch now I just got a new MacBook and I haven't done anything to this yet so it's right out of the box so the only thing that I've done is go through the initial setup of creating a new user connecting to my home Wi-Fi so that I can access the Internet and also I installed the software to record this video but that's it I don't have any of my development software installed on here or any of my personal preferences setup so for those of you have watched my videos before you've probably seen that I have my terminal set up in a certain way I have my editor customized how I like it and I also just have a lot of other different applications that I like to use so in this video I'm going to show you how I use scripts to automate the installation and setup for a large portion of this process and that's going to cut down on the time all of this takes pretty significantly so I used to not have any scripts like this and any time I got a new machine it would take me an entire day's worth of work to install all of the software and change all the settings to get it set up the way that I like it so this should definitely be something that you have scripted out so that you know everything gets set up exactly how you like it in as little time as possible so that's what we're going to do in this video now this is going to be Mac specific since that's what I use as my main development machine but you can likely create some sort of automation scripts like this for whatever operating system that you use so with that said let's go ahead and get

Installing Homebrew

started so first of all I'm going to install homebrew so I released a video last week on how to use homebrew for the Mac and I won't go into the deep details on that here but basically it's a package manager for the Mac operating system and it's going to allow us to install a lot of software from the command line in this case we're actually going to install a lot of software from scripts so if anyone is interested in learning more about how to use homebrew then you can go and watch that video from last week now before we install homebrew and we're going to make a quick change to my terminal so that it looks a little more like how I usually have it and also make the font larger so you can see it better so I'm going to open up my terminal here and if you've seen my videos before then you can probably tell this looks a lot different than how my terminal was usually set up but that's alright my scripts will get all of this set up here soon but first let me tweak the preferences here just a little so that we can see this a bit better so I'm going to open up my terminal preferences here and I'm going to go to profiles down here to Pro and set that as the default so that we have a dark background I'm also going to change the font here and I'm to a size of 30 and also I'm going to select this anti-alias text and for the background I think that the pro is a little bit too transparent so instead of that being 85% transparent I'm going to put it up in the 90s so I'll set that to 92 okay so now let me close that down and reopen it and now we can see that looks a little better we've got a dark background here and the text is larger so that everyone can see that okay so now let's install homebrew so to do that I'm just going to open a browser here and go to home brews home page so that we can get this installed now I don't have any other browsers installed so I'm going to use Safari here and I'm just going to search for homebrew Mac and go to their home page and right at the top of their home page they have the command for how to install homebrew so this is a ruby command and we're going to run this within our terminal so I'm just going to copy that and then let me minimize the browser and I'm going to paste that into my terminal so now I'm going to run that and then says to hit enter to return and now we also need to put in our password so now that's going to install homebrew so I am going to pause the video and then pick this back up whenever that finishes okay so that homebrew installation was successful it says here now I should have said this as I was installing homebrew but you have to be an administrator on your machine to install some of these things now I'm the sole user on my new laptop so I'm already an administrator but if you're not an administrator then you need to be on your machine okay so now that we have homebrew installed now I'm going to pull down my automation scripts from my github page I put my scripts up on github so that I can pull them down on to any machine but first let me make sure that git is actually installed so that we can clone that repository so if I run git then it looks like it displays the git commands so that works well sometimes it will ask you to install the command line developer tools but I believe that installed those command line developer tools for us whenever we installed homebrew okay so git seems to be working so now I'm going to pull down everything that I use to automate my software installations and preferences now these are in a repository on my github called dot files now that repository name is a bit misleading because it started out as just a repository for my dot files and now it's a repository for a few additional scripts as well but that's no big deal so let me go to that repository I'm just

Cloning Git

going to open it up in the browser so I'm going to do a search here for Cori Schaefer github and that should take me to my github page okay so now within here I'm going to open my dot files repository and let me make the screen a little larger here so that you can see now I'm just going to click on this section here where it says clone or download and now I'm going to copy that URL that it says to clone the repository so now I will go back to my terminal and I'm just going to simply say git clone and I'm going to clone that repository right inside of my home directory so I am in my home directory and you should be too so I'm going to run that and now if I do an LS then we can see that we have a dot files directory here on or within my home folder so that created my dot files directory in my home folder and that dot files folder has all of my dot files and scripts that will automate a lot of this setup so let me give you a quick overview of these scripts and what they're going to do now a lot of these are bash scripts so let me go back to github to look at these scripts and this dot files directory so I'm going to open up my github here and this is the dot files repository that we just cloned and now we can take a look at some of these files so first I'm going to open this install dot Sh script here and if I scroll down to take a look at this let me walk through this script and again let me make this text just a little larger here so that everyone can see okay so at the very top we can see that this is a bass script and the comment here says this script creates symlinks from the home directory to any desired dot files in the home directory ford slash dot files and it also installs homebrew packages and sets sublime preferences so the first line here is basically just telling us how to use this script so we're going to say install dot SH and then point our home directory or pass in our home directory as an argument and if it doesn't then it'll just echo that out saying that saying that we need to do that so we're going to set a couple of variables here our home directory is going to be equal to that first argument and then we're setting our dot file directory here to that home directory forward slash dot files and now we have a list of files and folders here and these are the dot files that I have within that dot files repository so we have bash profile bash RC bash prompt aliases and this one's private and now we CD into that dot files directory and then we create symlinks and it says here it will overwrite the old dot files we're creating symlinks for all of those dot files within that files list so we are echoing out that we're creating a symlink for these different files and here is where we're actually creating that symlink so this is the target dot file here and that is the file that is actually within our dot files repository and we're creating a symlink in our home directory called dot and then the file so dot bash RC dot bash underscore profile and so on so after that we are doing a little something extra we're downloading a get auto-completion script so that we have get auto completion within our terminal and then

Autocompletion

I'm running this homebrew script sublime script so that is the installation script now let me go back here and we can take a look at some more of these files so now we could take a look at some of these dot files here so these dot files can figure a lot of what I like to have in my terminal so for example bash prompt that will change the colors of my username and show me what directory I'm in and things like that and I have a separate video going in-depth as to what some of these dot files are doing so I'll leave a link to that video in the description section below if anyone is interested to see more details about how this stuff works but in this video we're just going to focus more on finishing the setup of this machine so the alias is dot file

Alias

here just has a bunch of aliases that I have while using my command line so for example let's see what one of these dot files look like I'm going to open up the aliases here and we can see that we just have a bunch of shortcuts so I have one here called CH that I use for commit history and what that'll do is just run the history command and then pipe in that output and search for get commits in the history so if I just type CH it's going to show me all the all my latest get commits hg is just history grep so if i want to search my history for something then i can just say you know if i wanted to look at the latest brew installed and i could just say hg brew and it'll show me all of the history commands that have brew in the command and just things like that that's basically what these dot files are doing so i'm going to go back here and the best profile is actually what gets run when you open up your terminal and within here it just sources all of the files so I say for file in bash prompt aliases private just source those files and it also does the get auto completion there as well so that is how those aliases and the prompt gets set from that bash profile so the dot file

Installing Applications

section of that install script that we saw just links all of those dot files in to my home phone so that all of that works now the applications for my machine are all going to get installed in this homebrew script and that's called Brutus H so let me take a look at that so if I scroll down here so we can see at the top here that I'm installing a couple of brew packages so we're installing Python by default Mac doesn't have Python 3 installed and that's what brew will install here I'm also installing the tree command and those are the only command line applications that I'm installing for now here are the Mac OS applications that I'm installing using brew cask and again if you don't know the difference between brew install and brew cask install then I would just recommend going to watch that homebrew tutorial that I did a week ago but this is really what's gonna save me a lot of time here this is where we're installing all kinds of applications so I'm installing Chrome Firefox sublime text VirtualBox source tree Spotify discord my Google Drive backup and sync Skype VLC hyper doc Divi hyper doc and Divi are applications that help you organize different applications on your desktop and then down here at the bottom I'm also installing the font that I like so I like this source code Pro font so I can install that using brew cask as well and I also had to tap a different repository here to install that ok so now I'm going to go back here now

Sublime Text Script

normally I would install more software in those scripts such as docker and ansible and things like that but I'm going to try to put a video on those subjects together in the near future so I want to show how to install those from scratch in those videos but you can add any additional software that you'd like to scripts like this ok and lastly if you remember in that install script I'm also running this sublime dot Sh script here at the bottom so let's take a look at that so I'm going to open that up and scroll down here a little bit and I'm doing a couple of things here so this downloads the package control package from their website and then it's putting it into my settings and it's calling it package control dot sublime package and then I am copying from those settings and putting those into we're sublime text has these installed on the operating system so it should be in this location here in my home folder for slash library forward slash applications support sublime text 3 and installed packages and these have spaces in here so these back spaces kind of make this look a little weird they'll really were just escaping those spaces there now this two forged slash def and all here at the end just means that we're ignoring any errors so if that directory doesn't exist then it's just going to ignore that and not display it to the screen I the reason I put that in is because maybe sublime text will change this install location at some point okay so I'm also installing my own custom sublime text settings here by copying from my settings directory and that's also in my dot files repository we'll take a look at that here in a second and these are my sublime settings and we're just putting those where sublime text expects those as well and also I'm creating some Python build systems here I'm creating one for Python 2 and Python 3 and I'm putting those where python or where sublime text expects those build systems and lastly I'm creating a sim link here to the su BL command so sublime text has an su BL command where you can use PI or use sublime text within the command line but they don't put it in your path automatically so that's what I'm doing here ok and just to show you one last thing here let me also show you what some of those settings look like so this is my settings folder here and we can see that I have some different things set up here so I have my sublime settings here my anaconda settings these are my build systems here and I also have my keyboard shortcuts here that I prefer as well now I don't think I had those keyboard shortcuts in that sublime script so that might be a mistake on my part so I'll have to actually add that in manually but after this video I'll probably add it to that sublime script so that gets automated as well but I'm not going to worry about it for this video now one

Desired Packages Script

thing I haven't been able to get work in terms of automating sublime text is for my desire packages to get installed automatically so if I open up my sublime settings here I looked it up online and apparently if I have this setting set here these installed packages and have my preferred packages in here then whenever we start up sublime it should look at those and if they're not installed then it should install those automatically but I've never got that to work so if anyone from sublime maintainer sees this video or if someone who knows what I'm doing wrong there then I'd be interested to know because it would be nice to automate that portion as well okay and lastly one more thing about these scripts here is that they need to be executable so mine were committed as executables so they shouldn't need to be changed but if you're creating scripts like this on your own then you could let me make this smaller and go back to the command line here let me CD in to dot files if I do an LS - la then these are executable here but if they weren't and you were creating your own then you could just do something like this chmod whoops chmod plus X and then the name of your script so that's how you make something executable okay so now

Installation Script

let me actually run this installation script to set up this machine now I know I've been talking a good bit in this video to show you what these scripts are going to do but if you imagine this process without me explaining everything along the way then it actually goes extremely quickly to run these scripts and get this machine set up so let me run these scripts and get these installations started so I can do that by saying first let me get my home directory here so I'm going to do a PWD and just grab my home directory I'm not going to grab the dot files part because remember I need to pass in the home directory as an argument to that installation script so I'm going to say dot Forge slash install dot SH and then pass in that home directory so I'm going to run that and we can see that this starts downloading a few things here but I'm going to scroll up here to the top and it says changing to the dot files directory and then it created those symlinks there and then it went out and started downloading a few things here so now we can see homebrew is installing a few different things so let me scroll down here to the bottom and so it's getting Python three seven at the moment okay so this script has a lot to do so I am going to pause this video and then pick this back up once it's finished okay so that script just

Results

completed and installed a lot of software and that took I believe that started at 3:37 and now it is 346 so in less than 10 minutes we installed a ton of different software and changed a lot of different settings on our machine now there was one installation in there that required me to enter a password so if you do something like this then you might have to watch for that so that it doesn't hold up your scripts okay so that's a lot less time than it would have taken to do all of that manually in just a few minutes we installed let me look back at the software here so we installed Python 3 Google Chrome Firefox sublime text VirtualBox source trees Spotify discord Google Drive Skype VLC different fonts and changed all kinds of different settings so a script like this can save you a ton of time so let's see what this did so first of all I'm going to shut down my terminal here and I'm going to open back up my terminal and we can see here that now my terminal looks more like it does in my normal videos because those dot files are now changing my preferences here to where I have the colors and settings that I like now this is still using this other font I'm hoping that my source code pro font was installed through that homebrew script so let's test that out if I go to preferences here and then try to change the font let's see if that font let me go to all fonts and see if source code Pro was installed and it was perfect ok so there it is got the source profond that i want and now that has changed now let's also look at our applications to make sure it looks like a lot of these applications were installed so we have backup and sync from Google that's the same as Google Drive the replacement we have discord Divi Firefox Google Chrome and all of those it looks like all of those were installed correctly so that's great okay so now let's see if some of those Google whoops let me

Testing

see if some of those homebrew packages that I wanted to stall install actually got installed so by default Python 3 isn't installed on a new Mac but it should have been installed through homebrew since it was in my script so if I say python 3 then we can see that now I have Python 3 on this machine so that's great so also and installed some other commands that aren't available by default and one of those was the tree command so if I clear my screen here and I say tree I'm going to do a tree on that dot files directory if I run that then we can see that tree works as well and that now we have a nice tree directory structure of my dot Files directory here within my command line now I'm not going to go over every little thing that was installed but I would like to check sublime text and make sure that it was installed as well so our sublime script should have created a command line shortcut for us to open sublime with the SU BL command so I should be able to open the dot files directory within sublime simply by saying SUV L dot files so let's try that ok and it looks like that works as well so whenever you first install some applications it might ask you if you're sure you want to open it I'll just say open there and now we have sublime text opened up here and instead of making this full screen let me actually just in large this instead whoops let me just enlarge this here now like I was saying before sublime it should look at my

Troubleshooting

settings and see that installed packages setting and go out and automatically install those packages but I've never actually got that to war so before I check if that worked let me instead just make sure that I have my settings file where it should be so if I go to settings okay it doesn't look like I have my sublime text settings here for some reason so let me check why this is if I go to browse packages here let me see where this is actually located on my machine so what I can do is drag this into my terminal okay so I'm actually not sure why that didn't work because it looks like that is the correct path that I would expect let me instead try to run that script manually because maybe it didn't work for some reason so I'm going to CD into my dot files and let me try to run that sublime @sh script manually so if I run that then let me go back to my sublime text here okay and it looks like that worked now so now I have all of my custom settings here let me restart sublime and see if it picks up any of those changes now sometimes these automation scripts I mean they can save you a ton of time but sometimes you run into things like this where you need to make some minor tweaks okay so let me close that down and I'm getting some errors here because it's saying that it can't find the installed packages so that is a problem that I've always had it before so we should at least have package control installed so we do and if I do that then we can try to install some of those packages manually so for example predawn is the theme and that's already looking a bit better and also if I install a package for the meat material theme let me install that and once that is installed then it should clear up some of this okay so now that material theme is installed then this is looking a bit better here and we can see that this looks more like how I normally have it set up but there are some differences here so I'm going to have to go in and install all of my other package is manually because I've never been able to get those to install automatically so I'm going to close down sublime text there for a second now I'm still not sure why that sublime script didn't run if I look at my installed Sh script so we have sublime dot SH is that the same name yeah so I'm not sure why that didn't run at the end of our installation but for some reason it seems like it didn't so I'm gonna have to go back and take a look at that and see exactly why that didn't install correctly so let me exit that out for now and also quit my terminal here okay but basically that's how I go about setting up a new development machine so we can see that these scripts carried a lot of the weight for us and did a ton of work that would have taken us a long time to do manually and not only does it take a long time to do stuff like this manually but if you don't have it scripted out then it's also prone to mistakes so for example I could you know forget to install that sublime text shortcut with the su BL command and then a couple of days later just have to do that and go out and figure that out and then I could realize that one of my settings are off and that I need to fix that you know having it automated like this just takes a lot of the headache out of the equation now that's usually as much as I oughta mate I'm constantly adding to these scripts and settings and also making corrections so the fact that it didn't run that sublime script is something that I'm gonna need to go in and fix and once I have that fixed I'll upload it to my github so that next time it works properly but I don't actually try to automate every little process if I think that it's going to be too difficult there are some things that I do manually so for example I'm going to manually sign-in to the programs that I installed so I need to go and sign in to Chrome and my Google Drive I need to log in to Spotify and things like that I'm going to you know manually rearrange my dock down here at the bottom now one thing that I usually do there is just take a snapshot of my dock from my last development machine and put it into my Google Drive so that I know that I have it how I had it now I also have my preferred desktop background saved in my Google Drive as well so after I sign in to that backup and sync from Google and once those files are actually synced to this computer then I can go in and change my desktop background as well but all of that stuff is just really minor and doesn't take much time at all of the big time-consuming items that I have scripted like all of the applications that we installed those go nice and quick like I was saying earlier before I had scripts like this it could really take me an entire day to get all of this software installed manually and set up all these preferences how I like them and now I've got that down to just a fraction of the time okay so I think that's gonna do it for this video hopefully you found this video interesting and learned a bit about how you can automate the setup of a new development machine even if you don't have as many personal preferences as I have even just using homebrew to install things like Chrome and the other applications that you use a lot will save you a lot of time but if anyone has any questions about what we covered in this video then feel free to ask in the comment section below and I'll do my best to answer those and if you enjoy these tutorials and would like to support them then there are several ways you can do that the easiest way is to simply like the video and give it a thumbs up and also it's a huge help to share these videos with anyone who you think would find them useful and if you have the means you can contribute through patreon and there's a link to that page in the description section below be sure to subscribe for future videos and thank you all for watching

Другие видео автора — Corey Schafer

Ctrl+V

Экстракт Знаний в Telegram

Экстракты и дистилляты из лучших YouTube-каналов — сразу после публикации.

Подписаться

Дайджест Экстрактов

Лучшие методички за неделю — каждый понедельник