Quick intro/history: ed editor Pros: low-bandwidth, installed pretty much everywhere, very fast and powerful for complicated and repetitive tasks Cons: Steep learning curve, different “modes” can be confusing at first Sublime and other desktop editors: nice for serious programming, but learn the basics of simple text editors even if you want to be a developer, you won't always be able to edit your code on your own desktop
Avoid Pico/Nano, Notepad++, SublimeText
Originally released 1976 name from Editor MACros for TECO editor, originally Tape Editor and COrrector at MIT in the '60s
But, along the way, I wrote a text editor, Emacs. The interesting idea about Emacs was that it had a programming language, and the user's editing commands would be written in that interpreted programming language, so that you could load new commands into your editor while you were editing. You could edit the programs you were using and then go on editing with them.-- Richard Stallman, http://www.gnu.org/gnu/rms-lisp.html
originally written for Amiga systems (Commodore PCs), 1988 vim released 1991 vimscript, Lua (as of Vim 7.3), Perl, Python, Racket, Ruby, Tcl (tool command language). vi written by Bill Joy in 1976, visual mode for line editor called ex line editors are from age of teleprinters, no cursors
What can the people around you help with?
Try both; choose one and get good at it
Your use case as a sysadmin or developer
How to tell?
-- INSERT -- 144,1 36% -- VISUAL -- 144,77 36%
Moving around in a file Search / replace Text manipulation, ie: cw, dw, c$, yy / p, x, .
h move one character to the left. j move down one line. k move up one line. l move one character to the right. 0 move to the beginning of the line. $ move to the end of the line. w move forward one word. b move backward one word. G move to the end of the file. gg move to the beginning of the file. . move to the last edit.
there are many many options and pre-existing packages to make editing nice for sysadmins and developers
Some sets of Vim plugins and configurations are available
Use them for research on what's available to improve dev productivity
You should know basic substitution:
This is not shell globbing
|Resources for learning:|
C-f forward one char (right) C-b backwards one char (left) M-f forward one word M-b backwards one word C-n forward one line (down) C-p backwards one line (up) C-a beginning of line C-e end of line C-o insert-newline and stay on current line C-j insert newline and indent C-v page down M-v page up M-< beginning of file M-> end of file M-g g <number> goto line <number> C-s forward search (C-s to keep searching)
C-x b switch buffers (type a new name to open a new buffer) C-x C-b list all buffers C-x C-f find file (opens a new buffer for the file) C-x k kill buffer C-x 1 close all windows but the main one C-x 2 split window horizontally C-x 3 split window vertically C-x o switch window
M-x eshell <RET> ;; yes, this gives a shell M-x server-mode <RET> ;; and then use emacsclient M-x compile ;; just "works" for most languages M-x package-install ;; emacs has packages!
M-x linum-modefor line numbers
M-x whitespace-modefor whitespace mode
$ vim testvim.txt $ emacs testemacs.txt <i> Hello world! Hello world! <alt + x> <esc> replace-regexp :%s/[aeiou]//g <enter> <enter> [aeiou] :wq <enter> <enter> <ctrl + x> <ctrl + s> <ctrl + x> <ctrl + c>
git, noun. Brit.informal. 1. an unpleasant or contemptible person.
$ sudo yum install git $ git config --global user.name "My Name" $ git config --global user.email "firstname.lastname@example.org" $ git config --global core.editor "emacs" $ git config --global push.default "current" # Or "nothing"
$ git init
$ git add <filename>
$ git commit -m "I did a thing!"
Undo things? the git book explains well
Did I remember to commit that?:
$ git status
What commits have I made lately?:
$ git log
This initializes a git repo. Use man git-init for more info.
This puts <filename> into the staging area. It isn't committed yet. Use
diff to see what changes aren't yet in staging.
This actually makes the commit. Use
git status to see what's in staging
but not yet committed. Use
git show or
git log to see recent commits.
Don't delete the .git directory
Avoid redundant copies of the same work in one revision
Don't make "oops, undoing that" commits.
- Use git commit --amend or git revert
Don't wait too long between commits
- You can squash them all together later
Don't commit secrets...
If you do commit secrets, reset them
Pull -> Work -> Add changes -> Commit -> Push
Larger projects have more complex workflows
The picture is of the Git Flow branching model, and you'll probably see it every single time anyone explains Git branching and merging to you.
On OSX, Linux:
$ ssh-keygen -t rsa -b 4096
Make sure to add a passphrase.
On Windows, we will let openstack generate one for you during the process
Also see ssh_keys for more detailed instructions
UserName: ONID username Password: ID # (change this)
On Linux or OSX, install
python-keystoneclient with pip:
$ pip install python-keystoneclient
keystone to change your password:
$ keystone --os-username <username> --os-password <your id> \ --os-auth-url http://studentcloud.osuosl.org:35357/v2.0/ \ password-update --new-password <new password>
DO NOT Use a password you have used elsewhere
If you're using Windows, spin up a VM on Openstack, then follow the above instructions.
Next we need to set up a key pair. Click on Security (the page in this picture) and then on Key Pairs
Click on Import Key Pair if you already have an SSH key pair
Windows users click on Create Key Pair and download the private key