Terminal and Editor
UNIX Essentials
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-spacebar
to open Spotlight, then typeTerminal
and hit enter - You now have a single terminal window. This window can open multiple tabs by typing
command-t
- The prompt on the left tells you a bit about what folder you’re currently in. But try typing
pwd
in the terminal and hit enter to print out your "present working directory"
Listing Files
ls
will list the files in the current folderls -lA
will 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_profile
you’ll work with later, are hidden files. If you just usels
they won’t show up, butls -lA
will show them. touch
is used to create blank files. Trytouch sample_file
thenls
.rm
is used to remove files. Remove that sample withrm sample_file
which
tells you where on the file system a program is. Trywhich ruby
to see the full path to your Ruby executable.
Working with Directories
mkdir
will make a directory. Go ahead and entermkdir sample_directory
to create a directorycd
stands for "change directory". Entercd sample_directory
to move into your new directory- The tilde (
~
) is a shortcut for your "home" directory. You can entercd ~
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 entercd .
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 enteringcd ..
thenls
and you should see your user folder.cd
back into that. - Removing directories is a bit different. Try
rm -rf sample_directory
to 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-spacebar
for spotlight, typeAtom
, and hit enter). - Click the
Atom
menu in the top left corner - Click
Install Shell Commands
- Return to your terminal and enter
which atom
. You should get back/usr/local/bin/atom
- Enter
atom .
to open your user directory in Atom. - Experiment with creating a file in Atom and using
ls
in the terminal to see it. Try creating a file in the terminal withtouch
and 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.
- Open
~/.bash_profile
in a text editor (ex:atom ~/.bash_profile
) - You can check out dotfiles on GitHub to see how serious people get: http://dotfiles.github.com/
The Essentials
export
to set environment variablesalias
for shorthand commands, like I definee
to launch my editorsource
to run scripts of bash commands
Dotfiles
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 |
|
Customizing Atom
Check out the Atom docs that explain how to start customizing it: https://atom.io/docs/latest/customizing-atom