If this is your first time using UNIX then you’ll need a few of the most essential pieces to be able to complete your work:
- Open Terminal by typing
command-spacebarto open Spotlight, then type
Terminaland hit enter
- You now have a single terminal window. This window can open multiple tabs by typing
- The prompt on the left tells you a bit about what folder you’re currently in. But try typing
pwdin the terminal and hit enter to print out your "present working directory"
lswill list the files in the current folder
ls -lAwill list the files in the current folder along with a bunch of info about them
Working with Files
- Files that start with a
., like the
.bash_profileyou’ll work with later, are hidden files. If you just use
lsthey won’t show up, but
ls -lAwill show them.
touchis used to create blank files. Try
rmis used to remove files. Remove that sample with
whichtells you where on the file system a program is. Try
which rubyto see the full path to your Ruby executable.
Working with Directories
mkdirwill make a directory. Go ahead and enter
mkdir sample_directoryto create a directory
cdstands for "change directory". Enter
cd sample_directoryto move into your new directory
- The tilde (
~) is a shortcut for your "home" directory. You can enter
cd ~from any folder on the system and you’ll jump back to your home directory.
- The single period (
.) is a reference to the current directory. If you enter
cd .it won’t go anywhere. But the period is useful especially with Git which you’ll see soon.
- The double period (
..) is a reference to the parent directory of the current directory (one step up the tree). Try entering
lsand you should see your user folder.
cdback into that.
- Removing directories is a bit different. Try
rm -rf sample_directoryto remove our previously created sample directory
Setting Up Terminal Access for Atom
One of the things you’ll do frequently is open an entire folder (like when working on a project) in your text editor. Let’s get that setup:
- Open Atom (
command-spacebarfor spotlight, type
Atom, and hit enter).
- Click the
Atommenu in the top left corner
Install Shell Commands
- Return to your terminal and enter
which atom. You should get back
atom .to open your user directory in Atom.
- Experiment with creating a file in Atom and using
lsin the terminal to see it. Try creating a file in the terminal with
touchand see if it shows up in Atom.
Customizing Your Terminal
A little bit of increased efficiency in your use of the Unix environment and your editor can pay significant dividends over time. Let’s experiment with customizing and adding to your terminal and editor.
~/.bash_profilein a text editor (ex:
- You can check out dotfiles on GitHub to see how serious people get: http://dotfiles.github.com/
exportto set environment variables
aliasfor shorthand commands, like I define
eto launch my editor
sourceto run scripts of bash commands
Snippets from my
.bash_profile are below.
The top three lines setup a yellow lightning bolt as my prompt because, well, it’s awesome.
We have set up some dotfiles you can use, go to bootstrap new students and follow the instructions there.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Check out the Atom docs that explain how to start customizing it: https://atom.io/docs/latest/customizing-atom