Skip to content

Instantly share code, notes, and snippets.

@biglovisa
Created April 4, 2018 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biglovisa/644f2d5da1d84b05a1ee3821500b9a92 to your computer and use it in GitHub Desktop.
Save biglovisa/644f2d5da1d84b05a1ee3821500b9a92 to your computer and use it in GitHub Desktop.
Shell and such
What is the terminal
a program that emulates the terminal
iterm or terminal most commonly
windows: https://www.quora.com/How-do-I-open-terminal-in-windows
What is the shell
a program that takes commands from the keyboard and gives them to the operating system to perform
operating system is what "does all the things"
performs tasks
recognizes keyboard input
sends things to the screen to display
talk to the operating system through a terminal or through a gui application/screen
What do you use it for
programming
many things you can do in the editor (manage files)
but some programs you can only interact with through the terminal
another tool in your toolbox
faster
more effective
tons to learn
- there must be a better way!
- warning signs: repetition, same steps
bash and zsh
- bourne again shell
- bash stays closer to POSIX (standard for operating system)
- bash stays compatible for more systems
- zsh does not avoid interactive features, like completion
- prompt, left and right prompt
- shared histories across terminals
- let's install zsh
- use which zsh to see if you have it
directory structure
- home directory
- echo $HOME (first command!)
- come back to this to demonstrate different shells
understanding the path
- echo $PATH
- whenever you run a command, your shell will look through the files in your path to find what to execute
- ls -la /usr/local/bin
- find a program (brew?) and execute it with the full path
- if you are unsure if something has been installed properly, run "which"
navigate the terminal
- cd (change directory) takes you $HOME
- cd - takes you back to the previous dir
different shells
- change env variable $HOME to something else
- navigate somewhere
- do cd $HOME
- get to the new place
- open up another shell, echo $HOME
- is it taking them to the same place
- why not?
sourcing of files
- when different shells open up, they source the same config
- exporting a var locally in a shell won't set it for others
- the context are the config files and the shell is the scope
- .{bash,zsh}rc, .{bash,zsh_profile
- _profile runs once on startup when you login
- bashrc is run when you start a new shell
- best practice is to source your bashrc in your bash_profile and keep all configs in bashrc
aliases
- very useful for things you are typing a lot
- alias hey="echo \"what\""
set up your dotfiles
- have all your configs in a version controlled repo
- easier to set up your computer next time
- cd
- mkdir .dotfiles
- symlinks to .gitignore and .gitconfig
- look at "man ln" to find out how to create them
- mkdir .dotfiles/zsh
- where I keep all my zsh files
- symlink zsh_profile.zsh and zshrc.zsh
- copy over the contents in different file before
- need to keep the extension!
- add prompt
- source .dotfiles/zsh/prompt.zsh in the zshrc.zsh
- prompt and rprompt
- colors %F{color}%f
- can use bash in the prompt
- google is your friend
- source aliases
- git aliases
- directory jumping
- common things you do
- functions
- download multiple videos
- ??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment