11 | includes:
12 | in_header: [google_analytics.html]
13 | bookdown::html_chapters:
14 | css: [style.css, toc.css]
15 | bookdown::pdf_book:
16 | includes:
17 | in_header: preamble.tex
18 | latex_engine: xelatex
19 | citation_package: natbib
20 | bookdown::epub_book:
21 | stylesheet: style.css
22 |
--------------------------------------------------------------------------------
/docs/libs/gitbook-2.6.7/css/plugin-table.css:
--------------------------------------------------------------------------------
1 | .book .book-body .page-wrapper .page-inner section.normal table{display:table;width:100%;border-collapse:collapse;border-spacing:0;overflow:auto}.book .book-body .page-wrapper .page-inner section.normal table td,.book .book-body .page-wrapper .page-inner section.normal table th{padding:6px 13px;border:1px solid #ddd}.book .book-body .page-wrapper .page-inner section.normal table tr{background-color:#fff;border-top:1px solid #ccc}.book .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n){background-color:#f8f8f8}.book .book-body .page-wrapper .page-inner section.normal table th{font-weight:700}
2 |
--------------------------------------------------------------------------------
/docs/libs/gitbook-2.6.7/css/plugin-search.css:
--------------------------------------------------------------------------------
1 | .book .book-summary .book-search {
2 | padding: 6px;
3 | background: transparent;
4 | position: absolute;
5 | top: -50px;
6 | left: 0px;
7 | right: 0px;
8 | transition: top 0.5s ease;
9 | }
10 | .book .book-summary .book-search input,
11 | .book .book-summary .book-search input:focus,
12 | .book .book-summary .book-search input:hover {
13 | width: 100%;
14 | background: transparent;
15 | border: 1px solid #ccc;
16 | box-shadow: none;
17 | outline: none;
18 | line-height: 22px;
19 | padding: 7px 4px;
20 | color: inherit;
21 | box-sizing: border-box;
22 | }
23 | .book.with-search .book-summary .book-search {
24 | top: 0px;
25 | }
26 | .book.with-search .book-summary ul.summary {
27 | top: 50px;
28 | }
29 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: r
2 | cache: packages
3 | script:
4 | - Rscript -e 'bookdown::render_book("index.rmd")'
5 | env:
6 | global:
7 | secure: pvgYZfGz3xiuiyGBMcjlIGcjYtVMc1/Gpg5UGSxkZTbTxaIEB+e6q5QWsYwltgy7nyOs4VUm0tm5KIZGjj9tWU7GUPqR8P3EeSaFJDKgulcxbF1T+oN+rrEg6pvpUqvpLESFghGlRVAx55ht9X4/pV5yHSTxC3Z207Ux5KifCn4OTGgkOcKx6KJ9YEZ5vXMwkwtuvX55Pca7Or7HJ2ZV/gk0Y1cB+t1UYnjDZukYBHs2gIml2i2sEixuBxKk4Isv33YMTFno4Hm/gdgsrZBrAmfTYe9DrAsdIoZfm6SsE8ElTKFWvAlbC/sxQryJg5eioBnDzgN0z7117YBcTbHMwVliwzOLNxk0zgQWYbIzrt7mk0JtJkFYN9EaBFWnqzCQCmpzR7w43WRQVFa6jMytu+z2dXstY+iMdV091dxw7pUQdi7Mwxabln6Fy/HJVo9YcJYv5rtbYiri955eMyQi2ygI3MEcPhdtTQorTI1J8wdgAFLVAVLERlupOs6/RTDW1rUq1UOFb4fqJHksU4EuRT3rV1hg8cVr5bBr7NMkOJrjRwbxGywrFlbq1EwZgAkHgZ/kUwdcvnZCHLcAvvOQMBQzowVdT3mZnzK9VWNK+jxzfnb3Gbw+m0tndSzlpy+dd2CW/DxMMTHxrGu4QAync7Xj/jcoBtpNGkrAwcq+cn4=
8 |
--------------------------------------------------------------------------------
/02-Getting-Unix.Rmd:
--------------------------------------------------------------------------------
1 | # Getting Unix
2 |
3 | > An indispensable thing never has much value. - Russian proverb
4 |
5 | ## Mac & Ubuntu Users
6 |
7 | If you're using a Mac or you're using the Ubuntu operating system find a
8 | program called **Terminal** and open it. You can skip the next section about
9 | Windows.
10 |
11 | ## Windows
12 |
13 | If you're using the latest version of Windows 10 you should enable and install
14 | Bash on Ubuntu on Windows. You can find the installation guide from Microsoft
15 | [here](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide).
16 |
17 | If you don't have the latest version of Windows 10 you should download
18 | [VirtualBox](https://www.virtualbox.org/) and then set up the latest version of
19 | Ubuntu with VirtualBox. Instructions for doing this tend to change slightly
20 | over time, so I suggest using Google to search for "how to install Ubuntu on
21 | Windows with VirtualBox" and then you can follow the instructions that you find.
22 |
--------------------------------------------------------------------------------
/docs/02-Getting-Unix.md:
--------------------------------------------------------------------------------
1 | # Getting Unix
2 |
3 | > An indispensable thing never has much value. - Russian proverb
4 |
5 | ## Mac & Ubuntu Users
6 |
7 | If you're using a Mac or you're using the Ubuntu operating system find a
8 | program called **Terminal** and open it. You can skip the next section about
9 | Windows.
10 |
11 | ## Windows
12 |
13 | If you're using the latest version of Windows 10 you should enable and install
14 | Bash on Ubuntu on Windows. You can find the installation guide from Microsoft
15 | [here](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide).
16 |
17 | If you don't have the latest version of Windows 10 you should download
18 | [VirtualBox](https://www.virtualbox.org/) and then set up the latest version of
19 | Ubuntu with VirtualBox. Instructions for doing this tend to change slightly
20 | over time, so I suggest using Google to search for "how to install Ubuntu on
21 | Windows with VirtualBox" and then you can follow the instructions that you find.
22 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to The Unix Workbench
2 |
3 | Contributions from anyone are welcome to this book! Please note that this
4 | project is released with a [Contributor Code of Conduct](CONDUCT.md). By
5 | participating in this project you agree to abide by its terms.
6 |
7 | ## How to Contribute
8 |
9 | First fork this repository and then clone your fork. Please only make changes
10 | to the `.md` and `.Rmd` files in the root of this directory. Once you've added,
11 | committed, and pushed your changes you should
12 | [submit a pull request](https://github.com/seankross/the-unix-workbench/compare/).
13 |
14 | If you're new to Git and GitHub you should read the
15 | [chapter of this book](http://seankross.com/the-unix-workbench/git-and-github.html)
16 | which explains how to use both.
17 |
18 | ## Adding Your Name to the Guestbook
19 |
20 | You are strongly encouraged to add your name to `guestbook.md` via pull request
21 | after reading the Git and GitHub section of this book. If you would like to
22 | add other edits to the book, please make them in a separate pull request.
23 |
--------------------------------------------------------------------------------
/01-What-is-Unix.Rmd:
--------------------------------------------------------------------------------
1 | # What is Unix?
2 |
3 | Unix is an operating system and a set of tools. The tool we will be using the
4 | most in this book is a shell, which is a computer program that provides a
5 | command line interface. You have probably seen a command line interface in the
6 | movies: an elite computer hacker sits in front of a black screen with green
7 | glowing text, furiously typing in commands and shouting something like
8 | "Spike them!" Using the command line interface lets you enter lines of code into
9 | a shell (also called a console) and that code instructs your computer to
10 | perform a specific task. Throughout this book I may use the terms command line,
11 | shell, and console interchangeably. You will learn about using the command line
12 | in the Command Line Basics chapter.
13 |
14 | The shell is a very direct and powerful way to manipulate a computer. You
15 | can produce wonderful creations that help thousands of people, or you can wreak
16 | havoc on yourself and on others. Like
17 | [Benjamin Parker](https://en.wikipedia.org/wiki/Uncle_Ben) once
18 | said: "With great power comes great responsibility."
19 |
20 | There are several popular shell programs but in this book we'll be using a shell
21 | called Bash because it is the default shell program on Mac and Ubuntu.
22 |
--------------------------------------------------------------------------------
/docs/01-What-is-Unix.md:
--------------------------------------------------------------------------------
1 | # What is Unix?
2 |
3 | Unix is an operating system and a set of tools. The tool we will be using the
4 | most in this book is a shell, which is a computer program that provides a
5 | command line interface. You have probably seen a command line interface in the
6 | movies: an elite computer hacker sits in front of a black screen with green
7 | glowing text, furiously typing in commands and shouting something like
8 | "Spike them!" Using the command line interface lets you enter lines of code into
9 | a shell (also called a console) and that code instructs your computer to
10 | perform a specific task. Throughout this book I may use the terms command line,
11 | shell, and console interchangeably. You will learn about using the command line
12 | in the Command Line Basics chapter.
13 |
14 | The shell is a very direct and powerful way to manipulate a computer. You
15 | can produce wonderful creations that help thousands of people, or you can wreak
16 | havoc on yourself and on others. Like
17 | [Benjamin Parker](https://en.wikipedia.org/wiki/Uncle_Ben) once
18 | said: "With great power comes great responsibility."
19 |
20 | There are several popular shell programs but in this book we'll be using a shell
21 | called Bash because it is the default shell program on Mac and Ubuntu.
22 |
--------------------------------------------------------------------------------
/CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Code of Conduct
2 |
3 | As contributors and maintainers of this project, we pledge to respect all people who
4 | contribute through reporting issues, posting feature requests, updating documentation,
5 | submitting pull requests or patches, and other activities.
6 |
7 | We are committed to making participation in this project a harassment-free experience for
8 | everyone, regardless of level of experience, gender, gender identity and expression,
9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
10 |
11 | Examples of unacceptable behavior by participants include the use of sexual language or
12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment,
13 | insults, or other unprofessional conduct.
14 |
15 | Project maintainers have the right and responsibility to remove, edit, or reject comments,
16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this
17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
18 | from the project team.
19 |
20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
21 | opening an issue or contacting one or more of the project maintainers.
22 |
23 | This Code of Conduct is adapted from the Contributor Covenant
24 | (http://contributor-covenant.org), version 1.0.0, available at
25 | http://contributor-covenant.org/version/1/0/0/
26 |
--------------------------------------------------------------------------------
/docs/libs/gitbook-2.6.7/css/plugin-bookdown.css:
--------------------------------------------------------------------------------
1 | .book .book-header h1 {
2 | padding-left: 20px;
3 | padding-right: 20px;
4 | }
5 | .book .book-header.fixed {
6 | position: fixed;
7 | right: 0;
8 | top: 0;
9 | left: 0;
10 | border-bottom: 1px solid rgba(0,0,0,.07);
11 | }
12 | span.search-highlight {
13 | background-color: #ffff88;
14 | }
15 | @media (min-width: 600px) {
16 | .book.with-summary .book-header.fixed {
17 | left: 300px;
18 | }
19 | }
20 | @media (max-width: 1240px) {
21 | .book .book-body.fixed {
22 | top: 50px;
23 | }
24 | .book .book-body.fixed .body-inner {
25 | top: auto;
26 | }
27 | }
28 | @media (max-width: 600px) {
29 | .book.with-summary .book-header.fixed {
30 | left: calc(100% - 60px);
31 | min-width: 300px;
32 | }
33 | .book.with-summary .book-body {
34 | transform: none;
35 | left: calc(100% - 60px);
36 | min-width: 300px;
37 | }
38 | .book .book-body.fixed {
39 | top: 0;
40 | }
41 | }
42 |
43 | .book .book-body.fixed .body-inner {
44 | top: 50px;
45 | }
46 | .book .book-body .page-wrapper .page-inner section.normal sub, .book .book-body .page-wrapper .page-inner section.normal sup {
47 | font-size: 85%;
48 | }
49 |
50 | @media print {
51 | .book .book-summary, .book .book-body .book-header, .fa {
52 | display: none !important;
53 | }
54 | .book .book-body.fixed {
55 | left: 0px;
56 | }
57 | .book .book-body,.book .book-body .body-inner, .book.with-summary {
58 | overflow: visible !important;
59 | }
60 | }
61 | .kable_wrapper {
62 | border-spacing: 20px 0;
63 | border-collapse: separate;
64 | border: none;
65 | margin: auto;
66 | }
67 | .kable_wrapper > tbody > tr > td {
68 | vertical-align: top;
69 | }
70 | .book .book-body .page-wrapper .page-inner section.normal table tr.header {
71 | border-top-width: 2px;
72 | }
73 | .book .book-body .page-wrapper .page-inner section.normal table tr:last-child td {
74 | border-bottom-width: 2px;
75 | }
76 | .book .book-body .page-wrapper .page-inner section.normal table td, .book .book-body .page-wrapper .page-inner section.normal table th {
77 | border-left: none;
78 | border-right: none;
79 | }
80 | .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr, .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr > td {
81 | border-top: none;
82 | }
83 | .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr:last-child > td {
84 | border-bottom: none;
85 | }
86 |
87 | div.theorem, div.lemma, div.corollary, div.proposition, div.conjecture {
88 | font-style: italic;
89 | }
90 | span.theorem, span.lemma, span.corollary, span.proposition, span.conjecture {
91 | font-style: normal;
92 | }
93 | div.proof:after {
94 | content: "\25a2";
95 | float: right;
96 | }
97 | .header-section-number {
98 | padding-right: .5em;
99 | }
100 |
--------------------------------------------------------------------------------
/toc.css:
--------------------------------------------------------------------------------
1 | #TOC ul,
2 | #TOC li,
3 | #TOC span,
4 | #TOC a {
5 | margin: 0;
6 | padding: 0;
7 | position: relative;
8 | }
9 | #TOC {
10 | line-height: 1;
11 | border-radius: 5px 5px 0 0;
12 | background: #141414;
13 | background: linear-gradient(to bottom, #333333 0%, #141414 100%);
14 | border-bottom: 2px solid #0fa1e0;
15 | width: auto;
16 | }
17 | #TOC:after,
18 | #TOC ul:after {
19 | content: '';
20 | display: block;
21 | clear: both;
22 | }
23 | #TOC a {
24 | background: #141414;
25 | background: linear-gradient(to bottom, #333333 0%, #141414 100%);
26 | color: #ffffff;
27 | display: block;
28 | padding: 19px 20px;
29 | text-decoration: none;
30 | text-shadow: none;
31 | }
32 | #TOC ul {
33 | list-style: none;
34 | }
35 | #TOC > ul > li {
36 | display: inline-block;
37 | float: left;
38 | margin: 0;
39 | }
40 | #TOC > ul > li > a {
41 | color: #ffffff;
42 | }
43 | #TOC > ul > li:hover:after {
44 | content: '';
45 | display: block;
46 | width: 0;
47 | height: 0;
48 | position: absolute;
49 | left: 50%;
50 | bottom: 0;
51 | border-left: 10px solid transparent;
52 | border-right: 10px solid transparent;
53 | border-bottom: 10px solid #0fa1e0;
54 | margin-left: -10px;
55 | }
56 | #TOC > ul > li:first-child > a {
57 | border-radius: 5px 0 0 0;
58 | }
59 | #TOC.align-right > ul > li:first-child > a,
60 | #TOC.align-center > ul > li:first-child > a {
61 | border-radius: 0;
62 | }
63 | #TOC.align-right > ul > li:last-child > a {
64 | border-radius: 0 5px 0 0;
65 | }
66 | #TOC > ul > li.active > a,
67 | #TOC > ul > li:hover > a {
68 | color: #ffffff;
69 | box-shadow: inset 0 0 3px #000000;
70 | background: #070707;
71 | background: linear-gradient(to bottom, #262626 0%, #070707 100%);
72 | }
73 | #TOC .has-sub {
74 | z-index: 1;
75 | }
76 | #TOC .has-sub:hover > ul {
77 | display: block;
78 | }
79 | #TOC .has-sub ul {
80 | display: none;
81 | position: absolute;
82 | width: 200px;
83 | top: 100%;
84 | left: 0;
85 | }
86 | #TOC .has-sub ul li a {
87 | background: #0fa1e0;
88 | border-bottom: 1px dotted #31b7f1;
89 | filter: none;
90 | display: block;
91 | line-height: 120%;
92 | padding: 10px;
93 | color: #ffffff;
94 | }
95 | #TOC .has-sub ul li:hover a {
96 | background: #0c7fb0;
97 | }
98 | #TOC ul ul li:hover > a {
99 | color: #ffffff;
100 | }
101 | #TOC .has-sub .has-sub:hover > ul {
102 | display: block;
103 | }
104 | #TOC .has-sub .has-sub ul {
105 | display: none;
106 | position: absolute;
107 | left: 100%;
108 | top: 0;
109 | }
110 | #TOC .has-sub .has-sub ul li a {
111 | background: #0c7fb0;
112 | border-bottom: 1px dotted #31b7f1;
113 | }
114 | #TOC .has-sub .has-sub ul li a:hover {
115 | background: #0a6d98;
116 | }
117 | #TOC ul ul li.last > a,
118 | #TOC ul ul li:last-child > a,
119 | #TOC ul ul ul li.last > a,
120 | #TOC ul ul ul li:last-child > a,
121 | #TOC .has-sub ul li:last-child > a,
122 | #TOC .has-sub ul li.last > a {
123 | border-bottom: 0;
124 | }
125 | #TOC ul {
126 | font-size: 1.2rem;
127 | }
128 |
--------------------------------------------------------------------------------
/docs/libs/gitbook-2.6.7/js/jquery.highlight.js:
--------------------------------------------------------------------------------
1 | gitbook.require(["jQuery"], function(jQuery) {
2 |
3 | /*
4 | * jQuery Highlight plugin
5 | *
6 | * Based on highlight v3 by Johann Burkard
7 | * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
8 | *
9 | * Code a little bit refactored and cleaned (in my humble opinion).
10 | * Most important changes:
11 | * - has an option to highlight only entire words (wordsOnly - false by default),
12 | * - has an option to be case sensitive (caseSensitive - false by default)
13 | * - highlight element tag and class names can be specified in options
14 | *
15 | * Copyright (c) 2009 Bartek Szopka
16 | *
17 | * Licensed under MIT license.
18 | *
19 | */
20 |
21 | jQuery.extend({
22 | highlight: function (node, re, nodeName, className) {
23 | if (node.nodeType === 3) {
24 | var match = node.data.match(re);
25 | if (match) {
26 | var highlight = document.createElement(nodeName || 'span');
27 | highlight.className = className || 'highlight';
28 | var wordNode = node.splitText(match.index);
29 | wordNode.splitText(match[0].length);
30 | var wordClone = wordNode.cloneNode(true);
31 | highlight.appendChild(wordClone);
32 | wordNode.parentNode.replaceChild(highlight, wordNode);
33 | return 1; //skip added node in parent
34 | }
35 | } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
36 | !/(script|style)/i.test(node.tagName) && // ignore script and style nodes
37 | !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
38 | for (var i = 0; i < node.childNodes.length; i++) {
39 | i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
40 | }
41 | }
42 | return 0;
43 | }
44 | });
45 |
46 | jQuery.fn.unhighlight = function (options) {
47 | var settings = { className: 'highlight', element: 'span' };
48 | jQuery.extend(settings, options);
49 |
50 | return this.find(settings.element + "." + settings.className).each(function () {
51 | var parent = this.parentNode;
52 | parent.replaceChild(this.firstChild, this);
53 | parent.normalize();
54 | }).end();
55 | };
56 |
57 | jQuery.fn.highlight = function (words, options) {
58 | var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
59 | jQuery.extend(settings, options);
60 |
61 | if (words.constructor === String) {
62 | words = [words];
63 | }
64 | words = jQuery.grep(words, function(word, i){
65 | return word !== '';
66 | });
67 | words = jQuery.map(words, function(word, i) {
68 | return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
69 | });
70 | if (words.length === 0) { return this; }
71 |
72 | var flag = settings.caseSensitive ? "" : "i";
73 | var pattern = "(" + words.join("|") + ")";
74 | if (settings.wordsOnly) {
75 | pattern = "\\b" + pattern + "\\b";
76 | }
77 | var re = new RegExp(pattern, flag);
78 |
79 | return this.each(function () {
80 | jQuery.highlight(this, re, settings.element, settings.className);
81 | });
82 | };
83 |
84 | });
85 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "The Unix Workbench"
3 | author: "Sean Kross"
4 | date: "2019-01-22"
5 | site: bookdown::bookdown_site
6 | output:
7 | bookdown::html_chapters:
8 | includes:
9 | in_header: style.css
10 | documentclass: book
11 | cover-image: "images/cover.png"
12 | bibliography: [book.bib]
13 | biblio-style: apalike
14 | link-citations: yes
15 | github-repo: seankross/the-unix-workbench
16 | url: 'https\://github.com/seankross/the-unix-workbench'
17 | description: ""
18 | ---
19 |
20 | # Title Page {-}
21 |
22 |
23 |
24 | Cover Image: *A Goldsmith in his Shop* by Petrus Christus
25 |
26 | [](https://creativecommons.org/publicdomain/zero/1.0/)
27 |
28 | This work by [Sean Kross](http://seankross.com) is licensed
29 | [CC0](https://creativecommons.org/publicdomain/zero/1.0/). Zero rights reserved.
30 |
31 | This book is available for purchase on [Leanpub.com](https://leanpub.com/unix).
32 |
33 | This book can be used on its own, however it's also the companion textbook to
34 | a course of the same name on [Coursera.org](https://www.coursera.org/learn/unix).
35 |
36 | # Dedication {-}
37 |
38 | In memory of Toby Kross.
39 |
40 | # Acknowledgements {-}
41 |
42 | Thank you to Jeff Leek, Roger Peng, and Brian Caffo for your advice and support.
43 | Also thank you to Jon Calder and Elissa Redmiles for your edits and suggestions.
44 |
45 | # Introduction {-}
46 |
47 | This book is intended for folks who are new to programming and new to Unix-like
48 | operating systems like macOS and Linux distributions like Ubuntu. Most of the
49 | technologies discussed in this book will be accessed via a command line
50 | interface. Command line
51 | interfaces can seem alien at first, so this book
52 | attempts to draw parallels between using the command line and actions that you
53 | would normally take while using your mouse and keyboard.
54 | You will also learn how to write little pieces of software in a programming
55 | language called Bash, which allows you to connect together the tools we will
56 | discuss. My hope is that by the end of this book you be able to use different
57 | Unix tools as if they are interconnecting Lego bricks.
58 |
59 | Unix forms a foundation that is often very helpful for
60 | accomplishing other goals you might have for you and your computer, whether
61 | that goal is running a business, writing a book, curing disease, or creating
62 | the next great app. The means to these goals are sometimes carried out by
63 | writing software.
64 | Software cannot be mined out of the ground, nor can software seeds be planted in
65 | spring to harvest by autumn. Software is not produced in factories on an
66 | assembly line. Software is a hand-made, often bespoke good. If a software
67 | developer is an artisan, then Unix is their workbench. Unix provides an
68 | essential and simple set of tools in a distraction-free environment. Even if
69 | you are not a software developer learning Unix can open you up to new methods
70 | of thinking and novel ways to scale your ideas. My goal
71 | for this book is to help you get started with Unix by writing the book I would
72 | have wanted when I was first learning Unix. If you have any additions,
73 | corrections, or comments for this book please open an issue or send a pull
74 | request to: https://github.com/seankross/the-unix-workbench. If you are unsure
75 | what a pull request is don't worry, you will find out in the Git and GitHub
76 | chapter of this book!
77 |
--------------------------------------------------------------------------------
/index.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "The Unix Workbench"
3 | author: "Sean Kross"
4 | date: "`r Sys.Date()`"
5 | site: bookdown::bookdown_site
6 | output:
7 | bookdown::html_chapters:
8 | includes:
9 | in_header: style.css
10 | documentclass: book
11 | cover-image: "images/cover.png"
12 | bibliography: [book.bib]
13 | biblio-style: apalike
14 | link-citations: yes
15 | github-repo: seankross/the-unix-workbench
16 | url: 'https\://github.com/seankross/the-unix-workbench'
17 | description: ""
18 | ---
19 |
20 | # Title Page {-}
21 |
22 |
23 |
24 | Cover Image: *A Goldsmith in his Shop* by Petrus Christus
25 |
26 | [](https://creativecommons.org/publicdomain/zero/1.0/)
27 |
28 | This work by [Sean Kross](http://seankross.com) is licensed
29 | [CC0](https://creativecommons.org/publicdomain/zero/1.0/). Zero rights reserved.
30 |
31 | This book is available for purchase on [Leanpub.com](https://leanpub.com/unix).
32 |
33 | This book can be used on its own, however it's also the companion textbook to
34 | a course of the same name on [Coursera.org](https://www.coursera.org/learn/unix).
35 |
36 | # Dedication {-}
37 |
38 | In memory of Toby Kross.
39 |
40 | # Acknowledgements {-}
41 |
42 | Thank you to Jeff Leek, Roger Peng, and Brian Caffo for your advice and support.
43 | Also thank you to Jon Calder and Elissa Redmiles for your edits and suggestions.
44 |
45 | # Introduction {-}
46 |
47 | This book is intended for folks who are new to programming and new to Unix-like
48 | operating systems like macOS and Linux distributions like Ubuntu. Most of the
49 | technologies discussed in this book will be accessed via a command line
50 | interface. Command line
51 | interfaces can seem alien at first, so this book
52 | attempts to draw parallels between using the command line and actions that you
53 | would normally take while using your mouse and keyboard.
54 | You will also learn how to write little pieces of software in a programming
55 | language called Bash, which allows you to connect together the tools we will
56 | discuss. My hope is that by the end of this book you be able to use different
57 | Unix tools as if they are interconnecting Lego bricks.
58 |
59 | Unix forms a foundation that is often very helpful for
60 | accomplishing other goals you might have for you and your computer, whether
61 | that goal is running a business, writing a book, curing disease, or creating
62 | the next great app. The means to these goals are sometimes carried out by
63 | writing software.
64 | Software cannot be mined out of the ground, nor can software seeds be planted in
65 | spring to harvest by autumn. Software is not produced in factories on an
66 | assembly line. Software is a hand-made, often bespoke good. If a software
67 | developer is an artisan, then Unix is their workbench. Unix provides an
68 | essential and simple set of tools in a distraction-free environment. Even if
69 | you are not a software developer learning Unix can open you up to new methods
70 | of thinking and novel ways to scale your ideas. My goal
71 | for this book is to help you get started with Unix by writing the book I would
72 | have wanted when I was first learning Unix. If you have any additions,
73 | corrections, or comments for this book please open an issue or send a pull
74 | request to: https://github.com/seankross/the-unix-workbench. If you are unsure
75 | what a pull request is don't worry, you will find out in the Git and GitHub
76 | chapter of this book!
77 |
--------------------------------------------------------------------------------
/08-Start-Building.Rmd:
--------------------------------------------------------------------------------
1 | # Start Building
2 |
3 | ## Next Steps
4 |
5 | We've reached the end of this book, which means that you now have a formidable
6 | foundation in using Unix. Congratulations! As the title of this book suggests
7 | Unix serves mostly as a workbench - a set of tools for building amazing digital
8 | creations. However, what you can create with Unix is usually not made out of
9 | Unix's constituent parts. You might use a hammer and saw to build a good
10 | birdhouse, but the birdhouse itself isn't made out of hammers. Working knowledge
11 | of Unix is best complemented by knowing at least one other programming language.
12 | Here are a few suggestions about how you can continue your computing and
13 | programming education.
14 |
15 | [**Python**](https://www.python.org/) is an approachable and essential language
16 | for anyone interested in computing. If you don't have any programming experience
17 | outside of this book, I very highly recommend learning Python. My favorite book
18 | on the subject is [Learn Python the Hard Way](https://learnpythonthehardway.org/book/)
19 | by Zed Shaw. Philip Guo's [Python Tutor](http://pythontutor.com/) allows you to
20 | visualize how Python is working under-the-hood, which allows you to develop a
21 | better intuition about the code you're writing. The pairing of those two
22 | resources is currently the best way to learn how to write software outside of
23 | formal university or corporate training. Once you have some Python experience
24 | you can try building your own HTTP API with [Flask](http://flask.pocoo.org/).
25 |
26 | [**R**](https://www.r-project.org/) is a general purpose programming language
27 | designed for folks who are interested in data science, analysis, modeling, and
28 | visualization. R is also fantastic for making digital documents: this book was
29 | created with R! If you want to get started with R I recommend the book
30 | [R Programming for Data Science](https://leanpub.com/rprogramming), the
31 | [Swirl](http://swirlstats.com/) software package, and the interactive R
32 | tutorial website called [DataCamp](https://www.datacamp.com/).
33 |
34 | [**JavaScript**](https://developer.mozilla.org/en-US/docs/Web/JavaScript) is
35 | the main language that powers the internet and it forms the backbone of web
36 | application programming. The Mozilla Development Network has
37 | [wonderful tutorials](https://developer.mozilla.org/en-US/docs/Web/Tutorials)
38 | about HTML, CSS, and JavaScript. Usually you use JavaScript to manipulate
39 | HTML and CSS, so learning about all three is important! I also recommend
40 | [NodeSchool](https://nodeschool.io/) for purely learning about JavaScript with
41 | Unix.
42 |
43 | ## Giving Feedback
44 |
45 | Thank you so much for reading this book! If you'd like to discuss the book or
46 | you have any feedback I would love to hear from you. The best way to contact me
47 | is [on Twitter](https://twitter.com/seankross).
48 |
49 | Now that you know how to use Git and GitHub you can submit changes that you
50 | think should be made to this book including fixing typos and correcting errors.
51 | You can find the repository for this book
52 | [here](https://github.com/seankross/the-unix-workbench). Fork the repository,
53 | and make your changes to the appropriate `.Rmd` file (just treat it like a
54 | regular Markdown file). Add, commit, and push your changes, then send me a pull
55 | request! While you're on the GitHub if you wouldn't mind giving this book's
56 | repository a [**Star**](https://github.com/seankross/the-unix-workbench) I
57 | would really appreciate it so that others can find this book more easily.
58 |
59 | ## Using this Book
60 |
61 | This book is released under a [CC0](https://creativecommons.org/publicdomain/zero/1.0/)
62 | license, meaning that it is dedicated to the public domain. If you think this
63 | book is worth paying for or you want to support the creation of more open source
64 | educational materials then consider buying the book
65 | on [Leanpub](https://leanpub.com/unix) where you are free to pay
66 | what you want, or send me a few dollars via [PayPal](https://www.paypal.me/seankross/5).
67 |
68 | If you use this book as part of a course or in any other setting please let me
69 | know!
70 |
--------------------------------------------------------------------------------
/docs/08-Start-Building.md:
--------------------------------------------------------------------------------
1 | # Start Building
2 |
3 | ## Next Steps
4 |
5 | We've reached the end of this book, which means that you now have a formidable
6 | foundation in using Unix. Congratulations! As the title of this book suggests
7 | Unix serves mostly as a workbench - a set of tools for building amazing digital
8 | creations. However, what you can create with Unix is usually not made out of
9 | Unix's constituent parts. You might use a hammer and saw to build a good
10 | birdhouse, but the birdhouse itself isn't made out of hammers. Working knowledge
11 | of Unix is best complemented by knowing at least one other programming language.
12 | Here are a few suggestions about how you can continue your computing and
13 | programming education.
14 |
15 | [**Python**](https://www.python.org/) is an approachable and essential language
16 | for anyone interested in computing. If you don't have any programming experience
17 | outside of this book, I very highly recommend learning Python. My favorite book
18 | on the subject is [Learn Python the Hard Way](https://learnpythonthehardway.org/book/)
19 | by Zed Shaw. Philip Guo's [Python Tutor](http://pythontutor.com/) allows you to
20 | visualize how Python is working under-the-hood, which allows you to develop a
21 | better intuition about the code you're writing. The pairing of those two
22 | resources is currently the best way to learn how to write software outside of
23 | formal university or corporate training. Once you have some Python experience
24 | you can try building your own HTTP API with [Flask](http://flask.pocoo.org/).
25 |
26 | [**R**](https://www.r-project.org/) is a general purpose programming language
27 | designed for folks who are interested in data science, analysis, modeling, and
28 | visualization. R is also fantastic for making digital documents: this book was
29 | created with R! If you want to get started with R I recommend the book
30 | [R Programming for Data Science](https://leanpub.com/rprogramming), the
31 | [Swirl](http://swirlstats.com/) software package, and the interactive R
32 | tutorial website called [DataCamp](https://www.datacamp.com/).
33 |
34 | [**JavaScript**](https://developer.mozilla.org/en-US/docs/Web/JavaScript) is
35 | the main language that powers the internet and it forms the backbone of web
36 | application programming. The Mozilla Development Network has
37 | [wonderful tutorials](https://developer.mozilla.org/en-US/docs/Web/Tutorials)
38 | about HTML, CSS, and JavaScript. Usually you use JavaScript to manipulate
39 | HTML and CSS, so learning about all three is important! I also recommend
40 | [NodeSchool](https://nodeschool.io/) for purely learning about JavaScript with
41 | Unix.
42 |
43 | ## Giving Feedback
44 |
45 | Thank you so much for reading this book! If you'd like to discuss the book or
46 | you have any feedback I would love to hear from you. The best way to contact me
47 | is [on Twitter](https://twitter.com/seankross).
48 |
49 | Now that you know how to use Git and GitHub you can submit changes that you
50 | think should be made to this book including fixing typos and correcting errors.
51 | You can find the repository for this book
52 | [here](https://github.com/seankross/the-unix-workbench). Fork the repository,
53 | and make your changes to the appropriate `.Rmd` file (just treat it like a
54 | regular Markdown file). Add, commit, and push your changes, then send me a pull
55 | request! While you're on the GitHub if you wouldn't mind giving this book's
56 | repository a [**Star**](https://github.com/seankross/the-unix-workbench) I
57 | would really appreciate it so that others can find this book more easily.
58 |
59 | ## Using this Book
60 |
61 | This book is released under a [CC0](https://creativecommons.org/publicdomain/zero/1.0/)
62 | license, meaning that it is dedicated to the public domain. If you think this
63 | book is worth paying for or you want to support the creation of more open source
64 | educational materials then consider buying the book
65 | on [Leanpub](https://leanpub.com/unix) where you are free to pay
66 | what you want, or send me a few dollars via [PayPal](https://www.paypal.me/seankross/5).
67 |
68 | If you use this book as part of a course or in any other setting please let me
69 | know!
70 |
--------------------------------------------------------------------------------
/docs/libs/gitbook-2.6.7/js/plugin-sharing.js:
--------------------------------------------------------------------------------
1 | gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
2 | var SITES = {
3 | 'github': {
4 | 'label': 'Github',
5 | 'icon': 'fa fa-github',
6 | 'onClick': function(e) {
7 | e.preventDefault();
8 | var repo = $('meta[name="github-repo"]').attr('content');
9 | if (typeof repo === 'undefined') throw("Github repo not defined");
10 | window.open("https://github.com/"+repo);
11 | }
12 | },
13 | 'facebook': {
14 | 'label': 'Facebook',
15 | 'icon': 'fa fa-facebook',
16 | 'onClick': function(e) {
17 | e.preventDefault();
18 | window.open("http://www.facebook.com/sharer/sharer.php?s=100&p[url]="+encodeURIComponent(location.href));
19 | }
20 | },
21 | 'twitter': {
22 | 'label': 'Twitter',
23 | 'icon': 'fa fa-twitter',
24 | 'onClick': function(e) {
25 | e.preventDefault();
26 | window.open("http://twitter.com/home?status="+encodeURIComponent(document.title+" "+location.href));
27 | }
28 | },
29 | 'google': {
30 | 'label': 'Google+',
31 | 'icon': 'fa fa-google-plus',
32 | 'onClick': function(e) {
33 | e.preventDefault();
34 | window.open("https://plus.google.com/share?url="+encodeURIComponent(location.href));
35 | }
36 | },
37 | 'linkedin': {
38 | 'label': 'LinkedIn',
39 | 'icon': 'fa fa-linkedin',
40 | 'onClick': function(e) {
41 | e.preventDefault();
42 | window.open("https://www.linkedin.com/shareArticle?mini=true&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title));
43 | }
44 | },
45 | 'weibo': {
46 | 'label': 'Weibo',
47 | 'icon': 'fa fa-weibo',
48 | 'onClick': function(e) {
49 | e.preventDefault();
50 | window.open("http://service.weibo.com/share/share.php?content=utf-8&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title));
51 | }
52 | },
53 | 'instapaper': {
54 | 'label': 'Instapaper',
55 | 'icon': 'fa fa-instapaper',
56 | 'onClick': function(e) {
57 | e.preventDefault();
58 | window.open("http://www.instapaper.com/text?u="+encodeURIComponent(location.href));
59 | }
60 | },
61 | 'vk': {
62 | 'label': 'VK',
63 | 'icon': 'fa fa-vk',
64 | 'onClick': function(e) {
65 | e.preventDefault();
66 | window.open("http://vkontakte.ru/share.php?url="+encodeURIComponent(location.href));
67 | }
68 | }
69 | };
70 |
71 |
72 |
73 | gitbook.events.bind("start", function(e, config) {
74 | var opts = config.sharing;
75 | if (!opts) return;
76 |
77 | // Create dropdown menu
78 | var menu = _.chain(opts.all)
79 | .map(function(id) {
80 | var site = SITES[id];
81 |
82 | return {
83 | text: site.label,
84 | onClick: site.onClick
85 | };
86 | })
87 | .compact()
88 | .value();
89 |
90 | // Create main button with dropdown
91 | if (menu.length > 0) {
92 | gitbook.toolbar.createButton({
93 | icon: 'fa fa-share-alt',
94 | label: 'Share',
95 | position: 'right',
96 | dropdown: [menu]
97 | });
98 | }
99 |
100 | // Direct actions to share
101 | _.each(SITES, function(site, sideId) {
102 | if (!opts[sideId]) return;
103 |
104 | gitbook.toolbar.createButton({
105 | icon: site.icon,
106 | label: site.text,
107 | position: 'right',
108 | onClick: site.onClick
109 | });
110 | });
111 | });
112 | });
113 |
--------------------------------------------------------------------------------
/docs/libs/gitbook-2.6.7/js/plugin-fontsettings.js:
--------------------------------------------------------------------------------
1 | gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
2 | var fontState;
3 |
4 | var THEMES = {
5 | "white": 0,
6 | "sepia": 1,
7 | "night": 2
8 | };
9 |
10 | var FAMILY = {
11 | "serif": 0,
12 | "sans": 1
13 | };
14 |
15 | // Save current font settings
16 | function saveFontSettings() {
17 | gitbook.storage.set("fontState", fontState);
18 | update();
19 | }
20 |
21 | // Increase font size
22 | function enlargeFontSize(e) {
23 | e.preventDefault();
24 | if (fontState.size >= 4) return;
25 |
26 | fontState.size++;
27 | saveFontSettings();
28 | };
29 |
30 | // Decrease font size
31 | function reduceFontSize(e) {
32 | e.preventDefault();
33 | if (fontState.size <= 0) return;
34 |
35 | fontState.size--;
36 | saveFontSettings();
37 | };
38 |
39 | // Change font family
40 | function changeFontFamily(index, e) {
41 | e.preventDefault();
42 |
43 | fontState.family = index;
44 | saveFontSettings();
45 | };
46 |
47 | // Change type of color
48 | function changeColorTheme(index, e) {
49 | e.preventDefault();
50 |
51 | var $book = $(".book");
52 |
53 | if (fontState.theme !== 0)
54 | $book.removeClass("color-theme-"+fontState.theme);
55 |
56 | fontState.theme = index;
57 | if (fontState.theme !== 0)
58 | $book.addClass("color-theme-"+fontState.theme);
59 |
60 | saveFontSettings();
61 | };
62 |
63 | function update() {
64 | var $book = gitbook.state.$book;
65 |
66 | $(".font-settings .font-family-list li").removeClass("active");
67 | $(".font-settings .font-family-list li:nth-child("+(fontState.family+1)+")").addClass("active");
68 |
69 | $book[0].className = $book[0].className.replace(/\bfont-\S+/g, '');
70 | $book.addClass("font-size-"+fontState.size);
71 | $book.addClass("font-family-"+fontState.family);
72 |
73 | if(fontState.theme !== 0) {
74 | $book[0].className = $book[0].className.replace(/\bcolor-theme-\S+/g, '');
75 | $book.addClass("color-theme-"+fontState.theme);
76 | }
77 | };
78 |
79 | function init(config) {
80 | var $bookBody, $book;
81 |
82 | //Find DOM elements.
83 | $book = gitbook.state.$book;
84 | $bookBody = $book.find(".book-body");
85 |
86 | // Instantiate font state object
87 | fontState = gitbook.storage.get("fontState", {
88 | size: config.size || 2,
89 | family: FAMILY[config.family || "sans"],
90 | theme: THEMES[config.theme || "white"]
91 | });
92 |
93 | update();
94 | };
95 |
96 |
97 | gitbook.events.bind("start", function(e, config) {
98 | var opts = config.fontsettings;
99 |
100 | // Create buttons in toolbar
101 | gitbook.toolbar.createButton({
102 | icon: 'fa fa-font',
103 | label: 'Font Settings',
104 | className: 'font-settings',
105 | dropdown: [
106 | [
107 | {
108 | text: 'A',
109 | className: 'font-reduce',
110 | onClick: reduceFontSize
111 | },
112 | {
113 | text: 'A',
114 | className: 'font-enlarge',
115 | onClick: enlargeFontSize
116 | }
117 | ],
118 | [
119 | {
120 | text: 'Serif',
121 | onClick: _.partial(changeFontFamily, 0)
122 | },
123 | {
124 | text: 'Sans',
125 | onClick: _.partial(changeFontFamily, 1)
126 | }
127 | ],
128 | [
129 | {
130 | text: 'White',
131 | onClick: _.partial(changeColorTheme, 0)
132 | },
133 | {
134 | text: 'Sepia',
135 | onClick: _.partial(changeColorTheme, 1)
136 | },
137 | {
138 | text: 'Night',
139 | onClick: _.partial(changeColorTheme, 2)
140 | }
141 | ]
142 | ]
143 | });
144 |
145 |
146 | // Init current settings
147 | init(opts);
148 | });
149 | });
150 |
151 |
152 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | CC0 1.0 Universal
2 |
3 | Statement of Purpose
4 |
5 | The laws of most jurisdictions throughout the world automatically confer
6 | exclusive Copyright and Related Rights (defined below) upon the creator and
7 | subsequent owner(s) (each and all, an "owner") of an original work of
8 | authorship and/or a database (each, a "Work").
9 |
10 | Certain owners wish to permanently relinquish those rights to a Work for the
11 | purpose of contributing to a commons of creative, cultural and scientific
12 | works ("Commons") that the public can reliably and without fear of later
13 | claims of infringement build upon, modify, incorporate in other works, reuse
14 | and redistribute as freely as possible in any form whatsoever and for any
15 | purposes, including without limitation commercial purposes. These owners may
16 | contribute to the Commons to promote the ideal of a free culture and the
17 | further production of creative, cultural and scientific works, or to gain
18 | reputation or greater distribution for their Work in part through the use and
19 | efforts of others.
20 |
21 | For these and/or other purposes and motivations, and without any expectation
22 | of additional consideration or compensation, the person associating CC0 with a
23 | Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25 | and publicly distribute the Work under its terms, with knowledge of his or her
26 | Copyright and Related Rights in the Work and the meaning and intended legal
27 | effect of CC0 on those rights.
28 |
29 | 1. Copyright and Related Rights. A Work made available under CC0 may be
30 | protected by copyright and related or neighboring rights ("Copyright and
31 | Related Rights"). Copyright and Related Rights include, but are not limited
32 | to, the following:
33 |
34 | i. the right to reproduce, adapt, distribute, perform, display, communicate,
35 | and translate a Work;
36 |
37 | ii. moral rights retained by the original author(s) and/or performer(s);
38 |
39 | iii. publicity and privacy rights pertaining to a person's image or likeness
40 | depicted in a Work;
41 |
42 | iv. rights protecting against unfair competition in regards to a Work,
43 | subject to the limitations in paragraph 4(a), below;
44 |
45 | v. rights protecting the extraction, dissemination, use and reuse of data in
46 | a Work;
47 |
48 | vi. database rights (such as those arising under Directive 96/9/EC of the
49 | European Parliament and of the Council of 11 March 1996 on the legal
50 | protection of databases, and under any national implementation thereof,
51 | including any amended or successor version of such directive); and
52 |
53 | vii. other similar, equivalent or corresponding rights throughout the world
54 | based on applicable law or treaty, and any national implementations thereof.
55 |
56 | 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59 | and Related Rights and associated claims and causes of action, whether now
60 | known or unknown (including existing as well as future claims and causes of
61 | action), in the Work (i) in all territories worldwide, (ii) for the maximum
62 | duration provided by applicable law or treaty (including future time
63 | extensions), (iii) in any current or future medium and for any number of
64 | copies, and (iv) for any purpose whatsoever, including without limitation
65 | commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66 | the Waiver for the benefit of each member of the public at large and to the
67 | detriment of Affirmer's heirs and successors, fully intending that such Waiver
68 | shall not be subject to revocation, rescission, cancellation, termination, or
69 | any other legal or equitable action to disrupt the quiet enjoyment of the Work
70 | by the public as contemplated by Affirmer's express Statement of Purpose.
71 |
72 | 3. Public License Fallback. Should any part of the Waiver for any reason be
73 | judged legally invalid or ineffective under applicable law, then the Waiver
74 | shall be preserved to the maximum extent permitted taking into account
75 | Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76 | is so judged Affirmer hereby grants to each affected person a royalty-free,
77 | non transferable, non sublicensable, non exclusive, irrevocable and
78 | unconditional license to exercise Affirmer's Copyright and Related Rights in
79 | the Work (i) in all territories worldwide, (ii) for the maximum duration
80 | provided by applicable law or treaty (including future time extensions), (iii)
81 | in any current or future medium and for any number of copies, and (iv) for any
82 | purpose whatsoever, including without limitation commercial, advertising or
83 | promotional purposes (the "License"). The License shall be deemed effective as
84 | of the date CC0 was applied by Affirmer to the Work. Should any part of the
85 | License for any reason be judged legally invalid or ineffective under
86 | applicable law, such partial invalidity or ineffectiveness shall not
87 | invalidate the remainder of the License, and in such case Affirmer hereby
88 | affirms that he or she will not (i) exercise any of his or her remaining
89 | Copyright and Related Rights in the Work or (ii) assert any associated claims
90 | and causes of action with respect to the Work, in either case contrary to
91 | Affirmer's express Statement of Purpose.
92 |
93 | 4. Limitations and Disclaimers.
94 |
95 | a. No trademark or patent rights held by Affirmer are waived, abandoned,
96 | surrendered, licensed or otherwise affected by this document.
97 |
98 | b. Affirmer offers the Work as-is and makes no representations or warranties
99 | of any kind concerning the Work, express, implied, statutory or otherwise,
100 | including without limitation warranties of title, merchantability, fitness
101 | for a particular purpose, non infringement, or the absence of latent or
102 | other defects, accuracy, or the present or absence of errors, whether or not
103 | discoverable, all to the greatest extent permissible under applicable law.
104 |
105 | c. Affirmer disclaims responsibility for clearing rights of other persons
106 | that may apply to the Work or any use thereof, including without limitation
107 | any person's Copyright and Related Rights in the Work. Further, Affirmer
108 | disclaims responsibility for obtaining any necessary consents, permissions
109 | or other rights required for any use of the Work.
110 |
111 | d. Affirmer understands and acknowledges that Creative Commons is not a
112 | party to this document and has no duty or obligation with respect to this
113 | CC0 or use of the Work.
114 |
115 | For more information, please see
116 |
--------------------------------------------------------------------------------
/docs/libs/gitbook-2.6.7/js/plugin-search.js:
--------------------------------------------------------------------------------
1 | gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
2 | var index = null;
3 | var $searchInput, $searchLabel, $searchForm;
4 | var $highlighted, hi = 0, hiOpts = { className: 'search-highlight' };
5 | var collapse = false;
6 |
7 | // Use a specific index
8 | function loadIndex(data) {
9 | // [Yihui] In bookdown, I use a character matrix to store the chapter
10 | // content, and the index is dynamically built on the client side.
11 | // Gitbook prebuilds the index data instead: https://github.com/GitbookIO/plugin-search
12 | // We can certainly do that via R packages V8 and jsonlite, but let's
13 | // see how slow it really is before improving it. On the other hand,
14 | // lunr cannot handle non-English text very well, e.g. the default
15 | // tokenizer cannot deal with Chinese text, so we may want to replace
16 | // lunr with a dumb simple text matching approach.
17 | index = lunr(function () {
18 | this.ref('url');
19 | this.field('title', { boost: 10 });
20 | this.field('body');
21 | });
22 | data.map(function(item) {
23 | index.add({
24 | url: item[0],
25 | title: item[1],
26 | body: item[2]
27 | });
28 | });
29 | }
30 |
31 | // Fetch the search index
32 | function fetchIndex() {
33 | return $.getJSON(gitbook.state.basePath+"/search_index.json")
34 | .then(loadIndex); // [Yihui] we need to use this object later
35 | }
36 |
37 | // Search for a term and return results
38 | function search(q) {
39 | if (!index) return;
40 |
41 | var results = _.chain(index.search(q))
42 | .map(function(result) {
43 | var parts = result.ref.split("#");
44 | return {
45 | path: parts[0],
46 | hash: parts[1]
47 | };
48 | })
49 | .value();
50 |
51 | // [Yihui] Highlight the search keyword on current page
52 | hi = 0;
53 | $highlighted = results.length === 0 ? undefined : $('.page-inner')
54 | .unhighlight(hiOpts).highlight(q, hiOpts).find('span.search-highlight');
55 | scrollToHighlighted();
56 | toggleTOC(results.length > 0);
57 |
58 | return results;
59 | }
60 |
61 | // [Yihui] Scroll the chapter body to the i-th highlighted string
62 | function scrollToHighlighted() {
63 | if (!$highlighted) return;
64 | var n = $highlighted.length;
65 | if (n === 0) return;
66 | var $p = $highlighted.eq(hi), p = $p[0], rect = p.getBoundingClientRect();
67 | if (rect.top < 0 || rect.bottom > $(window).height()) {
68 | ($(window).width() >= 1240 ? $('.body-inner') : $('.book-body'))
69 | .scrollTop(p.offsetTop - 100);
70 | }
71 | $highlighted.css('background-color', '');
72 | // an orange background color on the current item and removed later
73 | $p.css('background-color', 'orange');
74 | setTimeout(function() {
75 | $p.css('background-color', '');
76 | }, 2000);
77 | }
78 |
79 | // [Yihui] Expand/collapse TOC
80 | function toggleTOC(show) {
81 | if (!collapse) return;
82 | var toc_sub = $('ul.summary').children('li[data-level]').children('ul');
83 | if (show) return toc_sub.show();
84 | var href = window.location.pathname;
85 | href = href.substr(href.lastIndexOf('/') + 1);
86 | if (href === '') href = 'index.html';
87 | var li = $('a[href^="' + href + location.hash + '"]').parent('li.chapter').first();
88 | toc_sub.hide().parent().has(li).children('ul').show();
89 | li.children('ul').show();
90 | }
91 |
92 | // Create search form
93 | function createForm(value) {
94 | if ($searchForm) $searchForm.remove();
95 | if ($searchLabel) $searchLabel.remove();
96 | if ($searchInput) $searchInput.remove();
97 |
98 | $searchForm = $('