The command line shell and git¶
The default shell on OSX is bash, which is taught in this set of lessons: https://swcarpentry.github.io/shell-novice/ or in this detailed bash reference
if you are on Windows, powershell is somewhat similar – here is a table listing commands for both shell side by side taken from this in-depth powershell tutorial
Using the command line¶
Powershell and Bash common commands¶
To go to your $HOME folder:
cd ~
or
cd $HOME
To open explorer or finder for the current folder:
windows explorer do:
start .
MacOs finder do:
open .
To move up one folder:
cd ..
To save typing, remember that hitting the tab key completes filenames
To configure powershell on windows¶
first start a powershell terminal with admin privileges, then type:
set-executionpolicy remotesigned
then, in your miniconda3 powershel profile, do:
Test-Path $profile
to see whether you have an existing profile.
if you don’t have a profile, then do the following (this will overwrite an existing profile, so be aware):
New-Item –Path $Profile –Type File –Force
To add to your profile, open with:
start $profile
To configure bash or zsh on MacOS¶
open a terminal then type either
open .bash_profile
or for Catalina
open .zshenv
Bash and powershell command reference¶
Cmdlet |
Alias |
Bash Equivalent |
Description |
---|---|---|---|
|
|
|
List the directories and files in the current location. |
|
|
|
Change to the directory at the given path. Typing |
|
|
|
Changes to the directory. |
|
|
|
Changes back to the previous directory after using |
|
|
( |
Creates a new item. Used with no parameter, the item is by default a file. Using |
|
none |
|
Creates a new directory. (See |
|
|
|
Open something using File Explorer (the GUI) |
|
|
|
Deletes something. Permanently! |
|
|
|
Moves something. Takes two arguments - first a filename (i.e. its present path), then a path for its new location (including the name it should have there). By not changing the path, it can be used to rename files. |
|
|
|
Copies a file to a new location. Takes same arguments as move, but keeps the original file in its location. |
|
|
|
Outputs whatever you type. Use redirection to output to a file. Redirection with |
|
|
|
Gets the contents of a file and prints it to the screen. Adding the parameter |
|
|
( |
Searches for specific content. |
|
|
( |
Gets statistical information about an object. Use |
|
none |
|
Redirection. Puts the output of the command to the left of |
|
none |
|
Piping. Takes the output of the command to the left and uses it as the input for the command to the right. |
|
none |
|
Gets the help file for a cmdlet. Adding the parameter |
|
none |
|
Exits PowerShell |
Remember the keyboard shortcuts of tab
for auto-completion and the up and down arrows to scroll through recent commands. These shortcuts can save a lot of typing!
Git¶
A good place to go to learn git fundamentals is this lesson https://swcarpentry.github.io/git-novice/
Pulling changes from the github repository¶
When we commit changes to the master branch and push to our github repository, you’ll need to download those changes to keep current. To do that:
open a shell
cd to the numeric repository
fetch the changes with:
git fetch origin
make sure you aren’t going to clobber any of your own files:
git status
you can ignore “untracked files”, but pay attention to any files labeled “modified”. Those will be overwritten when you reset to our commit, so copy them to a new name or folder.
Finally, get to our commit with:
git reset --hard origin/master
If that worked, then printing the most recent log entry:
git log -1
should tell you the most recent commit message, and it should agree with what you see at our github repository.
Books and tutorials¶
We will be referring to our version of David Pine’s Introduction to Python: http://phaustin.github.io/pyman. The notebooks for each chapter are included in the numeric_students/pyman folder.
If you are new to python, I would recommend you also go over the following short ebook in detail:
Jake Vanderplas’ Whirlwind tour of Python is available both as a set of notebooks which you can clone from github or as a free ebook: http://www.oreilly.com/programming/free/a-whirlwind-tour-of-python.csp
to get the notebooks do:
We will be referencing chapters from:
A Springer ebook from the UBC library: Numerical Python
with code on github:
git clone https://github.com/jrjohansson/numerical-python-book-code
Two other texts that are available as a set of notebooks you can clone with git:
My favorite O’Reilly book is:
Some other resources:
If you know Matlab, there is Numpy for Maltab users
Here is a python translation by Don MacMillen of Chapter 1 of his matlab guide
A general computing introduction: How to think like a computer scientist with an interactive version
[ ]: