diff --git a/source/assets/js/section.js b/source/assets/js/section.js index 96c67dc..aec1e71 100644 --- a/source/assets/js/section.js +++ b/source/assets/js/section.js @@ -2,16 +2,34 @@ function nav_hotkey(e) { var action_for_key = function(e) { switch (e.keyCode) { case 74: // 'j' + if ((window.innerHeight + window.scrollY) < document.body.scrollHeight) { + return 'down'; + } + return ''; + case 75: // 'k' + if (window.scrollY > document.body.scrollTop) { + return 'up'; + } + return ''; + case 76: // 'l' case 78: // 'n' return 'next'; - case 75: // 'k' + case 72: // 'h' case 80: // 'p' return 'prev'; } } + + const scrollStep = 50; var action = action_for_key(e); if (action == 'next' || action == 'prev') { var link = $('link[rel="'+action+'"]'); window.location.href = link[0].href; + } else if (action == 'up'){ + window.scrollTo(document.body.scrollLeft, + window.scrollY - scrollStep); + } else if (action == 'down'){ + window.scrollTo(document.body.scrollLeft, + window.scrollY + scrollStep); } } diff --git a/source/halp.html.erb b/source/halp.html.erb index c1cc43f..ceaa32e 100644 --- a/source/halp.html.erb +++ b/source/halp.html.erb @@ -12,7 +12,7 @@ title: HALP!
I'm going to assume you're on a branch. You can confirm this by typing git status
in your repo. The very first line should say "On branch master" (or "On branch very-important-branch" or whatever the name of the branch you're on is). If not, please make a backup of your directory before proceeding and try to get some expert help! I can't cover all the possibilities in a document like this, and I'd hate to lead you further astray at this point.
I'm going to assume you're on a branch. You can confirm this by typing git status
in your repo. The very first line should say "On branch main" (or "On branch very-important-branch" or whatever the name of the branch you're on is). If not, please make a backup of your directory before proceeding and try to get some expert help! I can't cover all the possibilities in a document like this, and I'd hate to lead you further astray at this point.
If the second line doesn't say "nothing to commit (working directory clean)", you have some unsaved changes. You might be able to save them by using 'git stash', or you might want to copy some files out somewhere else if you're really paranoid. Or, you just may not care...
@@ -24,9 +24,9 @@ title: HALP!Whatever branch you're on, here's the good news: Git keeps track of every commit that that branch has ever pointed to. It does this in what's called the 'reflog' (that's short for "reference log") for your branch, which lives in the following plain-text file: [repository-root]/.git/logs/refs/heads/[branch-name]. The reflog for the master branch is in .git/logs/refs/heads/master, and the reflog for very-important-branch is in .git/logs/refs/heads/very-important-branch, and so on.
+Whatever branch you're on, here's the good news: Git keeps track of every commit that that branch has ever pointed to. It does this in what's called the 'reflog' (that's short for "reference log") for your branch, which lives in the following plain-text file: [repository-root]/.git/logs/refs/heads/[branch-name]. The reflog for the main branch is in .git/logs/refs/heads/main, and the reflog for very-important-branch is in .git/logs/refs/heads/very-important-branch, and so on.
-So. Take a deep breath, go to the root of your repository at the command line, and type this: cat .git/logs/refs/heads/master
So. Take a deep breath, go to the root of your repository at the command line, and type this: cat .git/logs/refs/heads/main
You should see a bunch of lines of the form:
diff --git a/source/layouts/layout.erb b/source/layouts/layout.erb index eefa484..98bc7ab 100644 --- a/source/layouts/layout.erb +++ b/source/layouts/layout.erb @@ -95,7 +95,7 @@
- Think Like (a) Git copyright © 2011-2017 Sam Livingston-Gray is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
+ Think Like (a) Git copyright © 2011-2021 Sam Livingston-Gray is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Original template © 2011 · Vectors Community Theme · All Rights Reserved
Each page has links at the bottom to the previous and next section, so you can read through the site from beginning to end. If you find that you're already familiar with some of the concepts in a given section, you can use the sidebar navigation to skip to specific pages.
-Keyboard junkies, you can also navigate between sections using the "N" and "P" keys, for (N)ext and (P)revious. Vim users may be pleased to know that "J" and "K" also work as they expect.
+Keyboard junkies, you can also navigate between sections using the "N" and "P" keys, for (N)ext and (P)revious. Vim users may be pleased to know that "J" and "K" keys work as up and down within page, and "H" and "L" keys move to previous and next page respectively.
(I used to have an "EPIC MODE" page that put almost all the content on one big long page, but I haven't been able to figure out how to replicate this using Middleman. Feel free to contact me if you know how to do this.)
diff --git a/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb b/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb index e81e4fc..ebd18bf 100644 --- a/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb +++ b/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb @@ -43,7 +43,7 @@ layout: sectiongit log --oneline --abbrev-commit --all --graph --decorate --color
-And, in fact, I have a shell alias in my dotfiles repository that does all of this:
+And, in fact, I have a shell alias in my dotfiles repository that does all of this:
alias gg='git log --oneline --abbrev-commit --all --graph --decorate --color'
diff --git a/source/sections/testing-out-merges/the-savepoint-pattern.html.erb b/source/sections/testing-out-merges/the-savepoint-pattern.html.erb
index 9b83eb2..1ddac82 100644
--- a/source/sections/testing-out-merges/the-savepoint-pattern.html.erb
+++ b/source/sections/testing-out-merges/the-savepoint-pattern.html.erb
@@ -23,7 +23,7 @@ layout: section
You're on the master branch and you want the changes from the spiffy_new_feature branch to be incorporated into master. You're reasonably confident that you'll want to keep the changes, but you want to be able to abort it if, for example, this feature has unintended side effects.
+You're on the main branch and you want the changes from the spiffy_new_feature branch to be incorporated into main. You're reasonably confident that you'll want to keep the changes, but you want to be able to abort it if, for example, this feature has unintended side effects.
git status
and you should see something like this:
- # On branch master
+ # On branch main
nothing to commit (working directory clean)
git branch savepoint
. Now, if you type git status
again, you should still see a message that you're on the master branch.
+ Type git branch savepoint
. Now, if you type git status
again, you should still see a message that you're on the main branch.
You're on the master branch and you want the changes from the spiffy_new_feature branch to be incorporated into master. You're not sure if this will be a good idea, so you want to try out the merge, but be able to abort it if things don't go smoothly.
+You're on the main branch and you want the changes from the spiffy_new_feature branch to be incorporated into main. You're not sure if this will be a good idea, so you want to try out the merge, but be able to abort it if things don't go smoothly.
git status
and you should see something like this:
- # On branch master
+ # On branch main
nothing to commit (working directory clean)
git checkout master
git merge test_merge
+ If YES: Move the main branch forward to where the test_merge branch is with:
+ git checkout main
git merge test_merge
git checkout master
git branch -D test_merge
+ git checkout main
git branch -D test_merge