# Automate Your Development Environment Setup with Scripts and Dotfiles

## Метаданные

- **Канал:** Corey Schafer
- **YouTube:** https://www.youtube.com/watch?v=ra5kMCXO-6I
- **Дата:** 05.03.2024
- **Длительность:** 30:08
- **Просмотры:** 65,922

## Описание

In this video, we'll be learning how I set up my development environments from scratch. I use scripts and dotfiles that I have saved on my Github page to make this process quick and easy. These scripts setup my terminal, VS Code, Sublime Text, and more. If you've ever wanted to know how I have my development environment set up or how I configure my settings, this video is for you. Let's get started...

My Dotfiles - https://github.com/CoreyMSchafer/dotfiles

Homebrew Tutorial - https://youtu.be/SELYgZvAZbU
Git Tutorial - https://youtu.be/HVsySz-h9r4
VS Code Setup (Mac) - https://youtu.be/06I63_p-2A4
VS Code Setup (Windows) - https://youtu.be/-nh9rCzPJ20

✅ 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/

#Python #Programming #Automation

## Содержание

### [0:00](https://www.youtube.com/watch?v=ra5kMCXO-6I) Segment 1 (00:00 - 05:00)

hey there how's it going everybody so I went to record some videos for you all the other day and unfortunately when I went to turn on my recording machine it wouldn't start up which isn't super surprising because I've had that machine for over 10 years now and it finally stopped working on me so I did have to go out and buy a new one and that is the one that I'm recording on now and this machine is pretty much in the exact same state that it was when I took it out of the box so I haven't changed any settings or set up any of my development tools and I haven't installed any applications on this machine other than Camtasia and that's what I'm using for my screen recordings so this is completely brand new right now without any customizations so in this video what I wanted to do was show you how I go about setting up a new development machine for myself uh completely from scratch and I also get a lot of comments and emails asking you know what software I'm using and how I have all of my settings configured so hopefully after this video uh you'll be able to find out exactly where I have all these things saved and how I go about getting everything installed so that you can customize those to how you want to use them and when it comes to setting all this stuff up I actually don't like needing to remember everything off the top of my head so I have all of these things saved in automated scripts that I pull down from GitHub to set up my machine exactly how I like it and that way it's nice and predictable every time I set up a new machine uh and it does the same thing every single time now some of you may have clicked on this video thinking that I was going to show how to migrate one machine over to another uh using a backup or time machine for the Mac or something like that but whenever I do this I like to have fresh insulations of everything that's just a personal preference of mine uh when I get a new development machine I don't like migrating all my old backups over from one machine to another uh because over time our machines just get so cluttered and they have a lot of leftover software and things that are never deleted so I personally like to start freshh from scratch and that's pretty easy for me because my files and photos are saved in sync uh on a lot of cloud services so I don't really keep a lot of my stuff on a local machine that needs to be transferred over but for things that I do want to keep uh I just save those directly to a thumb drive and transfer them over that way and then that way all the applications and everything else are installed from scratch but with that said let's go ahead and get started and I'll show you exactly how I do this so first I'm going to need to actually grab those dot files that I use that have all those automated scripts and I have those set up on GitHub now I don't have Google Chrome installed because I haven't installed anything on here yet so I'm just going to use uh Safari and I'll just type in uh Cory shaer dot files it should take me there and then we'll kind of go over these so first let me go ahead and make the text a little bit larger so that everybody can see I'll maximize the window here a little bit and now let's scroll down and go over these dot files now I have done a video of these dot files before uh but that was a long time ago I think that was about five or six years ago now and a lot of these have changed actually I think this is basically a complete rewrite uh of what I had in that last video and I also uh rewrote my DOT files to have a readme file here um that walks through the steps that I'm going to take in this video to set up a new machine and actually you can see here in the documentation that after I release this video I'm actually going to put it within the readme file here uh as a reference um now one of the most important things I put right here at the top uh for important note before installation so the thing about these dot files is that these are uh highly personalized to my own preferences and the way that I do things and it will actually modify your system so whenever I run these scripts uh it moves files around it changes settings on the machine um it changes you know my desktop icon to the way that I like it for these videos and things like that um a lot of these changes are irreversible um if you don't know exactly what the script is doing so if you want a development environment like mine what I suggest is just forking a repository like this and that's exactly how I got started too I forked a repository of somebody's settings that I liked made my own changes and then over time it kind of became my own thing so just be aware of that it's important to know what this script actually does before you run it on your own machine uh because it is going to make some changes um so with that said why don't we go ahead and take a look at some of these scripts here to see exactly what this is going to do now I'm not going to go over every single detail as to what these installation scripts do uh but let's just get a broad overview of what's going on here um so the main entry point uh to these installations is in this install. sh

### [5:00](https://www.youtube.com/watch?v=ra5kMCXO-6I&t=300s) Segment 2 (05:00 - 10:00)

script so if we look at this then we can see that one of the first things that it does is it finds our home directory uh with this do files directory which is where we're going to clone the repository and here is where it copies over all of the dot files that we currently have which are uh these files over here bash profile bash prompt uh my zshell prompts and files and configurations things like that now what those dot files do is they set up my terminal in a specific way uh for example if I look at this um zshell file uh what this does is it loads other dot files here so it loads up my prompt aliases so if I look at my prompt this is just a custom prompt here um because if I open up my terminal now uh for those of you who are used to seeing my videos before uh you probably know that I have this customized to where um you know I has the my own colors setup and also um whenever I'm in a get repository it'll tell me the branch that I'm in uh within this prompt and everything here um so that's what this prompt here does so I actually have these setup both for bash and for Zell um so for example if I go to my bash prompts we can see that's basically the same thing uh both my bash and my zshell prompts are both uh using this shared prompt here uh which is code that works on both of them so promp git that's what shows the git branch that I'm on um I have this prompt V andv here which shows us if we are within a python virtual environment and then it just sets up the colors that I use and things like that so if I go back here to the installation script then the next thing that it does is it runs my uh Mac OS specific scripts now this is all kind of uh Mac specific since I work mainly on Macs a lot of this will work on Linux as well um but within Mac here you can see that we're just installing some command line tools I set up a couple of different things for the mouse uh the scroll Direction and things like that and then I'm putting my uh desktop icon to be uh the one that you know have probably seen in these videos before so just a very short Mac script here um one of the main things is within this brew. sh script and that's where it runs all of my home brew commands so if we look at that then this is where a lot of my applications get installed here so first I'm installing Homebrew and if uh you don't know what Homebrew is I actually have a separate video on that it's basically just a package manager for Max uh and also for Linux um and after that's installed then I come down here and I update it upgrade it just make sure that we're using all of the latest packages and then for the command line I'm installing python Bash zsh G tree pilent things like that um and then and I tried to comment this as much as I could so that uh you all could modify these if you want to modify these scripts um but right here we can see that I am modifying my system to change my shell to use the Homebrew version of zsh instead of uh the one that comes installed on the Mac and then I set up my git configurations here with my git uh username my git email and then what we do like I said I'm not going to go over every little bit here this is just setting up a virtual environment that I use for a lot of my tutorials now these applications here these are applications that I'm going to install with Homebrew cask and Cask is an actual application for my machine pro usually a guey application so here we can see that uh this installs Google Chrome Firefox uh Sublime Text Visual Studio uh Spotify Discord my Google Drive and things like that um then after that it installs some fonts that I like um and then I think that's basically it for that file so after that's done if we go back to the installation script we can see that it runs uh my VSS code settings and within here what it does is it installs some different extensions that I use for vs code um and anytime that I enjoy a another extension or something like that if I really like it and want to transfer that to my normal workflow then I'll just add it here to these scripts um so after it installs those extensions then it moves a couple of things around on my machine uh we can see here that it moves over my custom settings my custom key bindings and things like that now I did put a couple of safeguards in place for certain things uh so what this is doing here is it's uh backing up my old setting file and my old key bindings into a backup file here just in

### [10:00](https://www.youtube.com/watch?v=ra5kMCXO-6I&t=600s) Segment 3 (10:00 - 15:00)

case something goes wrong uh then I'll have those backups uh but these backups it only keeps one iteration of these so I probably could have made this to where it is keeping timestamp versions of these backups or something like that but like I said this is just my personal preferences and it's been working for me so this is how I have things set up and lastly if we look at our installation script again we can see that it comes down here uh to Sublime Text and Sublime Text this is I have everything set up here um so the supply text one's a little bit different than vs code because it actually has to be opened up until some different folders and directories are created uh so that's why I'm kind of opening up Sublime here and then uh closing it a few times uh just to make sure that everything gets installed correctly and the way that Sublime Text installs its packages is you set this package control settings file um so what I'm doing is copying my own over into uh the one that gets installed through Homebrew and then I open up Sublime text automatically to install those packages um now in this settings directory this is actually part of my files repository here uh this is just a couple of different things that I use for settings so uh we can see here that uh for example these are my vs code settings here that get copied over um these are some of my Sublime Tech settings for my linter um my main Sublime Tech settings here um so all of these are things that just get um automatically moved to the correct locations whenever I run these scripts so now that we've seen uh a broad overview and again if you actually want to look at these uh I would highly recommend looking through uh the readme file here and diving in and taking a look at it yourself but now that we've looked at this got a briad overview of what's going on and know all the cavey Huts about running this code um let's go ahead and run it on this machine and see how it works so what I'm going to do here is I'm going to uh grab the URL to this repository and now I can actually close down my browser after I have that and now I'm going to open up terminal here we can see that we already have it open and normally when you open up terminal it should put you directly into your home folder so I'm in my uh corms home folder here if you're not then you can just hit CD and enter and that should take you to your home directory or you can use uh CD with the Tilda and that should take you to your home directory as well um so now that I'm in my home directory here if I do an LS we just have the normal things uh my desktop my documents things like that um what I'm going to do is I'm going to say get clone and then I'm going to paste in that files repository from GitHub so let's go ahead and run that now whenever I first run git on this machine uh we can see that it didn't actually run this so it says that no developer tools were found uh it's requesting to install now sometimes I've had this pop up for me before um it didn't pop up this time but we can see down here in the bottom right that if I click that then we do have a little uh popup here that says that we need to install git so I'm just going to go ahead and allow it to do that agree to the terms of service now most of these installations usually go fairly quickly um this one says 4 minutes right now it's probably not going to take four minutes it's probably just saying that and we'll update here in just a second but if any of these installations do take a little bit of time uh then what I'm going to do is just skip forward in the video a little bit until these installations are done um just so that you don't have to sit here and watch these installations uh install on my machine okay so now we can see that software was installed um so now let's go back here to the terminal where we tried to run that get command before and now I'm going to run get clone on that do files repo again and this time we can see that it pulled those down uh correctly so now I'm going to CD into that do files directory and this is just what we've looked at before if I do an lsla we can see that here I have all my DOT files and we've already taken a broad overview of some of these files so we have um my install script here Mac OS and my settings module and things like that now it does look like I have my Sublime liner settings out here uh messed around a little bit with this before making this video um I also have those in there so that's probably just a mistake it probably won't be there by the time I release this video um I probably just accidentally committed that and didn't see it um but let's look at these files again and like I said this installation script here uh install. sh that's the main entry point into these installations so now I'll just go ahead and run that uh we can see that it is executable over here so if I just do an install. sh let's go ahead and

### [15:00](https://www.youtube.com/watch?v=ra5kMCXO-6I&t=900s) Segment 4 (15:00 - 20:00)

run that and it'll go through the process of setting up my entire machine okay so we run that and it goes through and creates Sim links to all those dot files um now it's saying that the command line tools are already installed uh or else it would have tried to install those now a couple of these things it's going to ask for permissions like it wanted permission to uh set my desktop background there so I allowed that um now what it's trying to do is uh install Homebrew so uh some of these require pseudo access so I'll go ahead and put in my password here and this is just Homebrew telling us what it's going to install so I'll hit enter to accept that and now Homebrew is going to go through the installation of all the command line tools that I use and all of the applications like Google Chrome and things like that I use okay so one of the first breaks that it comes to in this installation script is uh telling me that it's trying to change my default shell uh to The Homebrew zshell so I'll go ahead and put in my password uh to accept that and put in my password again and that was successful now it's asking me to set up my git configuration so I'll go ahead and put in my information for git and like I said before these are all things that you can uh forget I don't like remember or I don't like needing to remember all of this off the top of my head so having it ask all of this information right off the bat uh for a onetime install I just like getting it all out of the way okay so now it looks like it's done installing most of those applications and the fonts and things like that um now there are a couple of manual things to go through uh in this installation process uh for example and whenever there is a manual step I just have it uh Echo out to the terminal here to tell me exactly what to do so here I'm telling myself to import my terminal settings now these are different from my Comm command line prompt settings and my DOT files this is actually going to customize um my actual terminal application uh with a different background and transparency and things like that so I'm just telling myself here to go to terminal settings profiles import and to uh import that from here so let me go to terminal settings and profiles and this is based off of this uh Pro profile here now to import we you click down here in the bottom left go to import and let's see this is in my home folder do files settings and I just named this CMS terminal here so let me choose CMS and then click to have this be my default profile for my terminal so now I'll just close that down and it's actually not going to apply those changes to the terminal until uh we restart but we don't want to do that now because we're still in the middle of our installation script so I'll go ahead and press enter to continue now at this point of the script I have it tell me to sign into a few different applications here uh because again the whole point of this script is to be completely done with everything after the script is finished running so I don't want to have to go through and think oh I forgot to sign in Spotify into Chrome so I just remind myself to it here manually um but I'm not going to do that here in this video because I don't want you all to have to uh watch me go through all that so where it says sign in to Chrome I sign in Chrome first because I use their password manager so that gives me access to all my other passwords um but I'm just going to press enter there skip signing in the Spotify Discord um now it's saying to open rectangle and give it the necessary permissions now that is the Windows manager that I use on a Mac so in order for that to um actually manage my windows I have to open it up for the first time here and give it access and then what we need to do here is open my system settings and actually give it access uh to be able to manage my windows so I'll go ahead and put in my password there and just use the uh recommended outof the-box behavior and now we have our settings here and this is actually another thing that I tell myself to do uh manually So within the script here after I have it uh give the necessary permissions I've already done that so I'll hit enter and now it says import your rectangle settings uh located in the settings rectangle config. js file so I'll just do that really quick import and again that was in my home folder files settings rectangle config. js and that should be set up how I like it now so now I'll go ahead and hit enter to continue and now it should continue

### [20:00](https://www.youtube.com/watch?v=ra5kMCXO-6I&t=1200s) Segment 5 (20:00 - 25:00)

on to uh the vs code stuff so this is installing my vs code applications okay so after it makes all of the changes that it needs to make to VSS code and gets that set up uh it's actually going to open my do files directory with nvs code and the reason I do this is because we can see here that I'm asking myself to log into certain extensions like co-pilot and things like that so again I'm not going to do that uh for this video it's also asking me to select some color themes um so one thing here let's open up these settings and whenever I open up the settings let me make the text a little bit larger so everybody can see um now you've probably seen uh this color scheme that I use in vs code in other videos uh but we can see that it installed all of those uh correctly and this is how I've had my vs code set up in other videos uh and that installation script did all of that for me so again like I said this is normally where I would go in and go to GitHub co-pilot and log in uh to my extensions that I have access to and things like that but I'm going to skip that for this video and do that later even though that kind of defies the purpose of why I have these scripts to begin with now one thing I noticed whenever I was testing this script on another machine for this video um whenever I run the VSS code part of this script I saw some warnings that popped up when it gets this vs code setup part of the script and I looked these up so one of these uh we can see here and then it says to um you know check electron and things like that now I look that up and as far as I can tell uh it looks like it has something to do with a release that they had in February um I don't think it has anything to do with my script uh and that'll likely be fixed when they make their next update I would assume but if not and those warnings Linger on for too long uh then I will give my script a look and see exactly what it could be but I can't imagine that it's anything that I'm doing because I'm just uh running some very simple code that installs some very popular uh extensions but even with these warnings for uh that code command um it hasn't affected anything on my end it still sets all of the uh settings and everything uh the way that it should so I'm going to go ahead and continue the script here now once this gets to the Sublime Text part of the script it's going to maybe look a little bit weird because of how Sublime Text Works uh you're going to see Sublime Text open and close a couple of times on its own and like I said earlier that's because unlike VSS code some of the settings and folders don't get created until Sublime Text is open for the first time and those need to be created before I move over my custom settings so that's what it's doing there in the background and now what it's doing here is we can see that it says that it's opening Sublime to automatically install packages and to press enter after all the packages are installed so whenever I moved over my package control settings and it had all of the applications within that file that I wanted to have installed we can see that it went through and it looks like it installed all of these correctly um now if you want to check within Sublime let me go ahead and make the text a little bit larger here um one thing that I would recommend is look down here in the bottom left and it'll show you if something is going on if a packag is installing uh there's nothing down there right now so these are probably all done but just to make uh double sure we can press uh control back tick and control back tick will open up our uh terminal down here at the bottom within Sublime Text and we can see everything that it did and check here for any errors but from what I can tell it looks like everything installed correctly so that looks good so I'm going to go ahead and close down Sublime Text go back to our script and press enter okay so after we closed down Sublime Text for the first time and continued with the installation it went over and moved all of my custom settings here um so now it looks a little bit more um if you've seen my videos uh how you would expect these scripts to look and we can see that it has the uh color themes and everything like that set up uh the way that I do in other videos so at this point the uh reason that I have this open back up again I say that um to go ahead and insert my Sublime teex license and things like that this is also where I like to check for errors so just to make sure that all of my custom settings are working properly I'll open up that terminal again um look for any errors that all looks good um so now I can just close this back down normally I would go ahead and put in my license key uh so that I'm not asked to enter it every time I'm working within Sublime um but since there's no errors and I'm not putting in my license key now uh I'm

### [25:00](https://www.youtube.com/watch?v=ra5kMCXO-6I&t=1500s) Segment 6 (25:00 - 30:00)

just going to go ahead and press enter there and we can see that now it says that the installation is complete okay so now that installation script is complete I'm going to go ahead and quit out of terminal and if I open that back up hopefully it has my terminal profile set up the way that I like it as well um so we can see that it's changed my uh prompt around here and if I navigate to that dot files directory which is a git repo then we can see here that uh my prompt is working to where it can tell that it's on a git repository and tells us that we are on the master Branch okay so this is all looking pretty good um you know you can test things as much as you want um if I wanted to see which zshell that I'm using I could do that and we can see that it appropriately set it up to where I'm using the homeb zshell I can do a brew list to see whoops and that's actually not uh-- list that's just a command for list so let me rerun that again and we can see that these are all the uh formula and cast that Brew installed okay so that's all looking good I'll go ahead and close down my terminal here and we can see that we have our desktop set as well but with that said that's basically it that's basically the entire process that I do on a new machine now that may have seemed like a long process since I was explaining everything along the way since I showed you the ins of an outs of you know a broad overview of what those dot files do but when I'm not recording and I'm only running these installation scripts uh that entire process actually goes by extremely quickly and gets my machines set up exactly how I like them in no time so if you are a developer who has a lot of you know customizations and different tools that you like to use I would highly recommend having a system like this uh set up in place for yourself before I used automated scripts like this you know I was constantly found myself forgetting how I set things up in a specific way needed to go back to my old machine to make sure everything was uh carried over correctly months later I would remember that I forgot to install a certain app that I used on a somewhat regular basis or that I forgot to log into something anything like that it just takes all the guesswork involved in stuff like that out um and doesn't keep me wondering if I've forgot something and then any time that I do use a new tool or um application uh what I'll do is I just keep these dot files here uh within my home folder and if I have a new tool that I want to add I just um come in here to myfile script and let's say that it's something I can install with Brew I'll just come down here and add it either to my packages for the command line or to my Cask list if it is you know like a browser or um something like that but with that said uh that's basically it uh now that I have this new machine set up I can actually record videos on here um so I'll be getting some new videos to you all very shortly that I have basically ready to go there's several uh that I already um have written and just need to be recorded So hopefully this video gave you all some ideas for how you can use some automated scripts in your own daily test uh and for anybody who's ever wondered or sent me messages as you know what software I'm using or how I have things configured um I hope that now you have a good idea of exactly where you can go uh to see exactly how I have things set up they're all in those dot files there now like I said I would highly recommend if you want a setup like mine um to Fork my repository and to make your own custom changes because like I said it's just going to make all of those changes on your system and if you had it set up in a certain way and it's going to overwrite all those settings that you had so make sure you know what the scripts are doing uh before you run them uh I don't want to get a lot of messages uh after people watch this video after I've given that disclaimer you know a hundred times now uh that my script messed up you know messed up your system so be careful is all I'm saying make sure you know what the scripts are doing um make your own customizations and test around with it uh before running my specific scripts that I use for myself but with that said if anybody has any questions about what we covered here 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 or YouTube and I'll leave links to those pages in the description section below be sure to subscribe for future videos and thank you all for watching

### [30:00](https://www.youtube.com/watch?v=ra5kMCXO-6I&t=1800s) Segment 7 (30:00 - 30:00)

oh

---
*Источник: https://ekstraktznaniy.ru/video/11733*