14
Shells ++

Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

Shells ++

Page 2: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

Terminal App?× On mac, there is terminal but you should use

iterm2× On Linux, I like terminator but others are also

good× On Windows, PowerShell but the linux subsystem

is probably good enough

Page 3: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

We talked about Bash

× Born Again SHell× There are other shells

× Z SHell× I like ZSH

× SPELL CORRECTION bc Im dum× Auto capitalization

× Also other stuff, but mostly that× Also it looks pretty

Page 4: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

OhMyZSH× The best version of ZSH

× So many features× Themes!× Git support

× You’ll learn about this later× Makes you look like a hacker!!

Page 5: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

ZSH vs BASH× They are different× There are a few subtle differences× You might have ZSH on your computer, but

Andrew and other CMU servers run BASH× We have never had an issue switching between

the two× Just remember that they’re not the same

Page 6: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

Lets install all this stuff!!

× ohmyz.sh× iterm2.com× Terminator: apt it

Page 7: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

.zshrc, .bash_profile, etc

× These files run on startup of terminal× Themes× Shortcuts× Aliases× A bunch of stuff to make your life easier

Page 8: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

Export and Source!× Source is the command you should run after

making changes to your .zshrc file or equivalent.× source ~/.zshrc

× Exported variables are available to the programs within the shell, whereas non exported variables are not available to these programs

×

Page 9: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

Shells are a language!!

× Functions are shell scripts!!!× So like (almost) every time your run anything

on your computer it’s running in the a× You can add things to your .zshrc or .bashrc or

.bash_profile (depending on your os/shell)× These things are in “scope” when you’re in terminal

× Like variables you use throughout your shell

Page 10: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

Let’s make some stuff× Removing is hard× I like to yeet stuff× So lets yeet things

× Add to your .zshrc or equivalent file× alias yeet=”rm -i”

× Remove this before you accidentally yeet -r

Page 11: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

That’s cool but let’s make it better

× Maybe you’ve handed in trainer lab?× You remember having to SCP stuff

× Gross!! no one likes this× Let’s make a shell function to do this for us

Page 12: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

GPI handin scriptgpihandin(){

labname=$1

scp "andrew:~/private/path/to/gpi-labs/$labname/handin.zip" ~/path/to/where/you/want/it/to/go

}

$ gpihandin trainerlab

Page 13: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

There is so much more!× Fish× ZSH plugins

× We can recommend some× Literally anything you want

Page 14: Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are a language!! × Functions are shell scripts!!! × So like (almost) every time your

Attendance × tinyurl.com/functions-are-zsh-scripts