# Linux/Mac Terminal Tutorial: Creating Aliases for Commands

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

- **Канал:** Corey Schafer
- **YouTube:** https://www.youtube.com/watch?v=0liXeoADU6A
- **Дата:** 01.08.2014
- **Длительность:** 11:07
- **Просмотры:** 42,730

## Описание

Speed up your work in the terminal with aliases. An alias is simply a shortcut for one or more terminal commands. 

In this video, we will walk through the process of creating and using your own aliases.


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

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

### [0:00](https://www.youtube.com/watch?v=0liXeoADU6A) <Untitled Chapter 1>

hey everybody I wanted to do a quick video on getting started with aliases in the terminal pretty much what an alias is it's just a shortcut for running terminal commands one or more terminal commands if you find yourself typing in the same commands over and over then it's usually a good idea to make an alias for that and it's gonna save you a lot of typing and also lets you work a lot faster so I'm already over here in the terminal so to start out let's go ahead and do a simple and we'll just write an alias to

### [0:37](https://www.youtube.com/watch?v=0liXeoADU6A&t=37s) change directory to the desktop

change directory to the desktop so normally how we would do this is we would just type in CD and to our desktop okay so now let's make an alias for that so let's just go back to our home directory and let's type in sudo nano and we want to go into the file dot bash underscore profile okay and as you can see mine is currently blank so to write our first alias all you have to do is type in alias and then the name of our alias this is just the shortcut for the command I'm going to call this DT since

### [1:24](https://www.youtube.com/watch?v=0liXeoADU6A&t=84s) changing the directory to the desktop

we're since it's changing the directory to the desktop and then equal sign with no spaces or anything and then two single quotes and within the single quotes we're going to put our command so CD and do the desktop okay let's go ahead and save that okay and for this to take effect we're gonna have to restart the terminal okay and now we should just be able to type in DT and it should change directory to our desktop okay so that shortcuts not going to save us a whole lot of time because it's such a short command but a lot of these commands can be a lot longer than that for example the command to show

### [2:15](https://www.youtube.com/watch?v=0liXeoADU6A&t=135s) show hidden files on your mac

hidden files on your Mac so if you see here on my desktop there are two hidden files that aren't showing up right now so I'll go ahead and type in the command to show those that is defaults right comm dot Apple finder see Apple show all files yes and then in order for that to take effect you have to restart finder to do that you do kill-all finder okay and now on the desktop here you can see these two hidden files that now show up and then to reverse that and hide the files again we have to do that same command but instead of yes type in no and then you have to restart finder again and now you can see that the files are hidden so that that's a lot to remember and it's such a long command it would be nice just to make an alias for that so let's go ahead and go back to your home directory and let's go ahead and open up that bash profile file again and I'm just going to go ahead and get rid of our alias for the changing directory to the desktop and instead let's make an alias for the command we just did I'm going to call that show files equals and then two quotes and within the quotes let's do defaults right com dot finder app will show all files yes and now that's one command and then we also need to run the command to restart the finder so to end this command you put in a semicolon and now you're still within the quotes here and with the semicolon it's saying okay I'm going to run that command and now we're gonna type in the second one kill-all finder okay now let's go ahead and do one to hide those files all so let's copy that let's paste this in and then study yes let's do no and instead of show files let's call that Hogg files let's go ahead and save our changes and let's restart terminal for those to take effect and now I should just be able to type in show files and if you look here at the desktop I'll hit enter and those hidden files show up and if I come over here and type in hide files and know that now those files are hidden so you can see how that shortcut saved us on a lot of timing and then we don't have to remember those long commands and those multiple commands so let me show you one more example here I have let me open up sublime text and I've made two more commands for myself and let me go ahead and open back up the bash profile file dot bash underscore profile and let me go down to the bottom here okay now these last two aliases that I had typed out here so say before I did a video tutorial if I wanted to do a few things say I wanted to come up here and instead of my clock being digital say I wanted to switch it to analog and also I might want to clean out my recycle bin and empty my downloads folder and also I may want to hide the dock when it's out of sight like that so instead of going through and doing all that stuff every time I want to start doing a screencast I can just make these aliases for me that will go through and do all that for me so let me go ahead and copy this one and paste it in and I'll walk through what it does okay so I'm calling this shortcut this alias I'm calling it Tut mode for tutorial mode and then the commands here I'm doing and I went ahead and put all the commands on new lines so that it's easier to read so I'm doing defaults right compal dot doc auto hide boolean to true that hides the doc to where here if you look at the bottom of the screen it'll hide the dock like that so that I don't have to have that up then it this command here kills the doc and restarts it so that takes effect then this command defaults right Compal menu extra clock is analog boolean is true that switches the clock up here to analog and then kill all system UI server restarts the menu bar up here and then these are just two regular terminal commands this command empties my trash can and downloads folder so and let me go ahead and copy and paste this command in and now this one

### [8:20](https://www.youtube.com/watch?v=0liXeoADU6A&t=500s) set everything back to normal

will set everything back to normal so this will unhide the dock restart it and set my clock to digital rather than analog and then I don't need to do anything with the trash and the Downloads folder because you know they've already been emptied anyway so let me go ahead and put something in my trash here so that we can make sure that all this works paste that there and let me just go ahead and put that in okay and then let me go ahead and save the bash profile then we need to let me go ahead and close down sublime text and I'll restart the terminal and now I should just be able to type in Tut mode here and if you look up here at the clock and the recycle bin the Downloads folder and the dock at the bottom it should go through all those okay so it set the clock to analog I scroll down here to my dock the Downloads folder is empty the trash can is empty and the dock hides whenever I move the mouse away from it and then if I do regular mode then it sets everything back to normal so you can see how that saves just a ton of time it makes it so much easier things you know don't have to go through and remember every single step I can just type that in and I know that it does everything that I wanted to do for me so it's really nice if you ever forget what you're what you named your aliases like instead of Tut mode maybe or reg mode maybe I would think it's regular mode or something if you ever forget what you named it then within your terminal here you can just type the word alias and it'll pop up all

### [10:20](https://www.youtube.com/watch?v=0liXeoADU6A&t=620s) pop up all the aliases

the aliases let me make this bigger here for you it'll come up with all the aliases that you've created so you can see here you have alias hide files and this is the command reg mode show files and the Tut mode you know you can explore more with these you can even do functions within that file so that you can open up programs with specific variables there's a lot you can do with it but I just wanted to give you a quick intro just to kind of show you to get you started so just you know go in there and start messing around with it and see what you come up with so hopefully this was useful for you guys and thanks for watching

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