Skip to content

Commit dd0909e

Browse files
committed
Initial commit
0 parents  commit dd0909e

18 files changed

+361
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_site/

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2011 Peter Mitchell
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.markdown

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Bash Tips
2+
[Bash Tips](http://www.bashtips.org/) is a blog containing tips and pointers on using the GNU Bourne Again SHell.
3+
4+
## Contributing
5+
You'll need [Jekyll](http://www.jekyllrb.com/) and [Sass](http://www.sass-lang.com/) to build the site.
6+
7+
If you find a typo, have suggestions for improvements or want to submit a post, create a fork and send a pull request. A post should have your name and uri in its [YAML Front Matter](https://github.com/mojombo/jekyll/wiki/yaml-front-matter). Look at a previous post for an example.
8+
9+
## License
10+
Content of the site is licensed under Creative Commons. The source code is licensed under the MIT license.

_config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
auto: false
2+
archive_offset: 10

_layouts/default.html

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<meta charset="utf-8"/>
4+
<head>
5+
<title>{{ page.title }}</title>
6+
<link rel="stylesheet" type="text/css" href="/css/screen.css"/>
7+
<link rel="alternate" type="application/atom+xml" title="Bash Tips feed" href="/atom.xml" />
8+
</head>
9+
<body>
10+
<header>
11+
<hgroup>
12+
<h1>
13+
<a href="/">Bash Tips</a>
14+
</h1>
15+
<h2>Tips for using the GNU Bourne-Again SHell.</h2>
16+
</hgroup>
17+
</header>
18+
{{ content }}
19+
<footer>
20+
<nav>
21+
<ul>
22+
<li><a href="/about.html">About</a></li>
23+
<li><a href="https://www.github.com/petmit/bashtips">Source code</a></li>
24+
<li>Licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative Commons Attribution 3.0 License</a></li>
25+
</ul>
26+
</nav>
27+
</footer>
28+
</body>
29+
</html>
30+

_layouts/post.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
layout: default
3+
---
4+
<article>
5+
<header>
6+
<hgroup>
7+
<h1>{{ page.title }}</h1>
8+
<h2>
9+
by <a href="{{ page.author.uri }}">{{ page.author.name }}</a> on
10+
<time datetime="{{ page.date | date_to_string }}" pubDate="pubDate">
11+
{{ page.date | date_to_string }}
12+
</time>
13+
</h2>
14+
</hgroup>
15+
</header>
16+
{{ content }}
17+
</article>

_plugins/sass_converter.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module Jekyll
2+
require 'sass'
3+
class SassConverter < Converter
4+
safe true
5+
priority :low
6+
7+
def matches(ext)
8+
@ext = ext
9+
@ext =~ /s[ac]ss/i
10+
end
11+
12+
def output_ext(ext)
13+
".css"
14+
end
15+
16+
def convert(content)
17+
if @ext =~ /\.scss$/i
18+
syntax = :scss
19+
else
20+
syntax = :sass
21+
end
22+
engine = Sass::Engine.new(content, :syntax => syntax, :style => :compact)
23+
engine.render
24+
end
25+
end
26+
end
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
layout: post
3+
author:
4+
name: Bash Tips
5+
uri: http://www.bashtips.org
6+
---
7+
Executing a command will return an exit status (0 if successful, non-zero otherwise). The exit status is stored in the special variable `$?`.
8+
9+
echo "Hello world"
10+
echo $?
11+
12+
will print `0` and
13+
14+
/bin/false
15+
echo $?
16+
17+
will print `1` (non-zero exit failure).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
layout: post
3+
author:
4+
name: Bash Tips
5+
uri: http://www.bashtips.org
6+
---
7+
When you execute a command, the shell will store it in a command line history. Using `fc` you can list and re-execute commands from your history.
8+
9+
fc -l
10+
11+
will list your 16 previous commands and
12+
13+
fc 130
14+
15+
will open command number 130 in an editor, allow you to edit it, and then execute it. You can pass the `-s` flag to to skip editing.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: post
3+
author:
4+
name: Bash Tips
5+
uri: http://www.bashtips.org
6+
---
7+
If you have typed command and you need to run it again with some minor changes, you can use quick substition event designators. Say you want to list the files in `/var/log/`.
8+
9+
ls /var/log/
10+
11+
If you decide you need to list the files in `/var/lib` instead, you can use
12+
13+
^log^lib
14+
15+
which will result in
16+
17+
ls /var/lib/
18+
19+
being executed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
layout: post
3+
author:
4+
name: Bash Tips
5+
uri: http://www.bashtips.org
6+
---
7+
The key combination `Ctrl-r` will allow you to search your command history and execute a previously typed command.
8+
9+
ls -l /var/log
10+
(reverse-i-search)`ls`: ls -l /var/log
11+
12+
Press `Esc` to leave search mode and return to prompt, or `Enter` if you want to execute a match.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
layout: post
3+
author:
4+
name: Bash Tips
5+
uri: http://www.bashtips.org
6+
---
7+
You can use `&&` and `||` to chain together commands and execute them conditionally, i.e. based on the value of the [exit status](/2011/10/15/exit-status.html) of the last command. `&&` will execute the second command only if the first is successful.
8+
9+
/bin/true && echo "foo"
10+
11+
will print `foo`. `||` will execute the second command only if the first is unsuccessful.
12+
13+
/bin/true || echo "foo"
14+
15+
will not print anything.

about.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
layout: default
3+
title: About
4+
---
5+
<article>
6+
<p>The <a href="http://www.gnu.org/software/bash/">GNU Bourne Again SHell</a> is the default <a href="http://en.wikipedia.org/wiki/Unix_shell">shell</a> on Linux and Apple MacOS X. It has a wealth of features, many of which are hidden deep in documentation. On this site you will find some tips and tricks for using Bash.</p>
7+
<p>While you may not find the most detailed of explanations here, you can always check the <code>man</code> pages of your shell or the <a href="http://www.gnu.org/software/bash/manual/bashref.html">bash reference manual</a> online for further information.</p>
8+
<p>If you find a typo, have suggestions for improvements or want to submit a post, feel free to <a href="https://www.github.com/petmit/bashtips/">create a fork on github</a> and send a pull request. You'll need <a href="http://www.ruby-lang.org/">Ruby</a>, <a href="http://www.jekyllrb.com/">Jekyll</a> and <a href="http://www.sass-lang.com/">Sass</a> to build the site.</p>
9+
<p>The icon used in the logo and as the favicon is from the <a href="http://www.famfamfam.com/lab/icons/silk/">silk icon set</a> from <a href="http://www.famfamfam.com/">famfamfam.com</a>.</p>
10+
</article>

atom.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
---
3+
<?xml version="1.0" encoding="utf-8"?>
4+
<feed xmlns="http://www.w3.org/2005/Atom">
5+
6+
<id>http://www.bashtips.org/</id>
7+
<link href="http://www.bashtips.org/atom.xml" rel="self"/>
8+
<link href="http://www.bashtips.org/"/>
9+
<title>Bash Tips</title>
10+
<subtitle>Tips for using the GNU Bourne-Again SHell.</subtitle>
11+
<updated>{{ site.time | date_to_xmlschema }}</updated>
12+
<author>
13+
<name>Bash Tips</name>
14+
<uri>http://www.bashtips.org/</uri>
15+
</author>
16+
17+
{% for post in site.posts %}
18+
<entry>
19+
<id>http://www.bashtips.org{{ post.id }}</id>
20+
<link href="http://www.bashtips.org{{ post.url }}"/>
21+
<title>{{ post.title }}</title>
22+
<updated>{{ post.date | date_to_xmlschema }}</updated>
23+
<author>
24+
<name>{{ post.author.name }}</name>
25+
<uri>{{ post.author.uri }}</uri>
26+
</author>
27+
<content type="html">{{ post.content | xml_escape }}</content>
28+
</entry>
29+
{% endfor %}
30+
31+
</feed>

css/screen.scss

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
---
3+
html, body {
4+
background: #FFF;
5+
color: #333;
6+
margin: 0;
7+
padding: 0;
8+
}
9+
body {
10+
max-width: 630px;
11+
margin: 0 auto;
12+
font: 1em Helvetica, Arial, Verdana, sans-serif;
13+
}
14+
h1, h2, ul {
15+
margin: 0;
16+
padding: 0;
17+
}
18+
a {
19+
text-decoration: none;
20+
color: #369;
21+
&:hover {
22+
text-decoration: underline;
23+
}
24+
}
25+
ul {
26+
list-style-type: none;
27+
}
28+
body > header hgroup {
29+
margin: 2em 0 2em;
30+
h1 {
31+
background: url("/images/application_osx_terminal.png") no-repeat left center;
32+
padding-left: 20px;
33+
font-size: 24px;
34+
a {
35+
text-decoration: none;
36+
color: #333;
37+
&:hover {
38+
text-decoration: none;
39+
}
40+
}
41+
}
42+
h2 {
43+
font-size: .9em;
44+
font-weight: normal;
45+
}
46+
}
47+
article {
48+
margin: 0 0 2em;
49+
header hgroup {
50+
margin-bottom: .8em;
51+
h1 {
52+
font-size: 1.5em;
53+
a {
54+
color: #333;
55+
text-decoration: none;
56+
&:hover {
57+
text-decoration: none;
58+
}
59+
}
60+
}
61+
h2 {
62+
font-size: .8em;
63+
font-weight: normal;
64+
a {
65+
color: inherit;
66+
text-decoration: none;
67+
font-weight: bold;
68+
}
69+
}
70+
}
71+
p {
72+
margin: 0 0 1em;
73+
> code {
74+
padding: 0 2px;
75+
}
76+
}
77+
pre, code {
78+
font: .9em "Bitstream Vera Sans Mono", "DejaVu Sans Mono", Monaco, monospace;
79+
background-color: #EEE;
80+
}
81+
pre {
82+
margin: 0 0 1em;
83+
padding: 7px;
84+
overflow: auto;
85+
}
86+
}
87+
section.archive {
88+
header h1 {
89+
font-size: 1.2em;
90+
margin: 0 0 1em;
91+
}
92+
ul li {
93+
margin: 1em 0;
94+
}
95+
}
96+
footer {
97+
border-top: 1px solid #CCC;
98+
margin: 2em 0 2em;
99+
font-size: .8em;
100+
padding: 10px 0;
101+
nav {
102+
ul li {
103+
display: inline;
104+
&+ li::before {
105+
padding: 0 6px;
106+
content: "\0020\2022\0020";
107+
}
108+
}
109+
}
110+
}

favicon.ico

1.12 KB
Binary file not shown.

images/application_osx_terminal.png

525 Bytes
Loading

index.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
layout: default
3+
title: Bash Tips
4+
---
5+
{% for post in site.posts limit: site.archive_offset %}
6+
<article>
7+
<header>
8+
<hgroup>
9+
<h1>
10+
<a href="{{ post.url}}">{{ post.title }}</a>
11+
</h1>
12+
<h2>
13+
by <a href="{{ post.author.url }}">{{ post.author.name }}</a> on
14+
<time datetime="{{ post.date | date_to_xmlschema }}" pubDate="pubDate">
15+
{{ post.date | date_to_string }}
16+
</time>
17+
</h2>
18+
</hgroup>
19+
</header>
20+
{{ post.content }}
21+
</article>
22+
{% endfor %}
23+
{% if site.posts.size > site.archive_offset %}
24+
<section class="archive">
25+
<header>
26+
<h1>Archive</h1>
27+
</header>
28+
<ul>
29+
{% for post in site.posts offset: site.archive_offset %}
30+
<li>
31+
<time datetime="{{ post.date | date_to_xmlschema }}">
32+
{{ post.date | date_to_string }}
33+
</time>
34+
» <a href="{{ post.uri }}">{{ post.title }}</a>
35+
</li>
36+
{% endfor %}
37+
</ul>
38+
</section>
39+
{% endif %}

0 commit comments

Comments
 (0)