Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are...
Transcript of Shells - Carnegie Mellon School of Computer Science07131/f19/topics/extratations/zsh · Shells are...
![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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/1.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/2.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/3.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/4.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/5.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/6.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/7.jpg)
.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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/8.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/9.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/10.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/11.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/12.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/13.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022042401/5f0fb2da7e708231d4457226/html5/thumbnails/14.jpg)
Attendance × tinyurl.com/functions-are-zsh-scripts