Skip to content

Commit d19057f

Browse files
authored
Merge pull request #36 from primis/master
Added an Install script
2 parents 8ebe0ae + 9e24c23 commit d19057f

File tree

5 files changed

+158
-10
lines changed

5 files changed

+158
-10
lines changed

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
PREFIX ?= /usr/local
2+
BASH_COMPLETION_DIR := $(shell pkg-config --silence-errors --variable=completionsdir bash-completion)
3+
# pkg-config adds a space for some reason, we have to strip it off.
4+
BASH_COMPLETION_DIR := $(strip $(BASH_COMPLETION_DIR))
5+
USERDIR ?= $(HOME)
6+
7+
# The @ symbols make the output silent.
8+
9+
install:
10+
@if [ $(BASH_COMPLETION_DIR) ]; then \
11+
cp notes.bash_completion "$(BASH_COMPLETION_DIR)/notes"; \
12+
else \
13+
printf \
14+
"Bash completion was not installed, because the directory was not found. \
15+
If you have bash completion installed, follow the README \
16+
(https://github.com/pimterry/notes#installing-bash-completion) \
17+
to manually install it.\n\n"; \
18+
fi # Small test for bash completion support
19+
@install -m755 -d $(PREFIX)/bin/
20+
@install -m755 notes $(PREFIX)/bin/
21+
@install -m777 -d $(USERDIR)/.config/notes/
22+
@install -m777 config $(USERDIR)/.config/notes/
23+
@install -d $(PREFIX)/share/man/man1/
24+
@install notes.1 $(PREFIX)/share/man/man1/
25+
26+
@mandb 1>/dev/null 2>&1 || true # Fail silently if we don't have a mandb
27+
28+
@printf \
29+
"Notes has been installed to $(PREFIX)/bin/notes. \
30+
A configuration file has also been created at $(USERDIR)/.config/notes/config, \
31+
which you can edit if you'd like to change the default settings.\n\n\
32+
Get started now by running 'notes new my-note' \
33+
or you can run 'notes help' for more info.\n"
34+
35+
uninstall:
36+
rm -f $(PREFIX)/bin/notes
37+
rm -f $(PREFIX)/share/man/man1/notes.1
38+
rm -f $(BASH_COMPLETION_DIR)/notes
39+
rm -f $(USERDIR)/.config/notes/config.example
40+
41+
@printf "\nNotes has now been uninstalled.\n"

README.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ This is just one tool in the chain. `notes` is a command line tool, and some peo
2121

2222
## How do I install this?
2323

24-
Download `notes`, `chmod +x`, put it in your `$path`. This will probably do it:
24+
### Automatic:
2525

2626
```bash
27-
curl https://cdn.rawgit.com/pimterry/notes/v0.2.0/notes > /usr/local/bin/notes && chmod +x /usr/local/bin/notes
27+
curl -L https://rawgit.com/pimterry/notes/latest-release/install.sh | bash
2828
```
29+
This will install `notes`, a default configuration, a man page, and bash completion if possible.
2930

30-
By default your notes live in ~/notes, but you can change that to anywhere you like by setting the `$NOTES_DIRECTORY` environmental variable. See [how do I configure this?](#how-do-i-configure-this) for more details.
31+
### Manual:
32+
33+
Download `notes`, `chmod +x`, put it in your `$path`. This will probably do it:
34+
35+
```bash
36+
curl https://cdn.rawgit.com/pimterry/notes/latest-release/notes > /usr/local/bin/notes && chmod +x /usr/local/bin/notes
37+
```
3138

3239
#### Installing auto completion
3340

@@ -42,25 +49,33 @@ Installing the completions might be as follows:
4249
**Bash**
4350

4451
```bash
45-
curl https://cdn.rawgit.com/pimterry/notes/v0.2.0/notes.bash_completion > /usr/share/bash-completion/completions/notes
52+
curl https://cdn.rawgit.com/pimterry/notes/latest-release/notes.bash_completion > /usr/share/bash-completion/completions/notes
4653
```
4754

4855
**Zsh**
4956

5057
On *buntu based distros and OSX:
5158
```bash
52-
curl -L https://rawgit.com/pimterry/notes/master/_notes > /usr/local/share/zsh/site-functions/_notes
59+
curl -L https://rawgit.com/pimterry/notes/latest-release/_notes > /usr/local/share/zsh/site-functions/_notes
5360
```
5461

5562
On other Unix distros:
5663

5764
```bash
58-
curl -L https://rawgit.com/pimterry/notes/master/_notes > /usr/share/zsh/site-functions/_notes
65+
curl -L https://rawgit.com/pimterry/notes/latest-release/_notes > /usr/share/zsh/site-functions/_notes
5966
```
6067

6168
You'll need to open a new shell for this to take effect.
6269

63-
# How do I configure this?
70+
## What if I want to uninstall this?
71+
If you used the automated install script to install notes, you can uninstall it the same way, by running:
72+
```bash
73+
curl -L https://rawgit.com/pimterry/notes/latest-release/install.sh | bash -s -- uninstall
74+
```
75+
76+
## How do I configure this?
77+
78+
By default your notes live in ~/notes, but you can change that to anywhere you like by setting the `$NOTES_DIRECTORY` environmental variable. See [how do I configure this?](#how-do-i-configure-this) for more details.
6479

6580
To get started with you'll want to set `$EDITOR` to your favourite text editor, and probably `$NOTES_DIRECTORY` to the directory in which you'd like to use to store your notes (this defaults to `~/notes`). You'll typically want to set these as environment variables in your `.bashrc`, `.zshrc`, or similar.
6681

config.example renamed to config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# This config is case sensitive
44

55
# Set the editor that notes are opened with
6-
EDITOR=nano
6+
# EDITOR=nano
77

88
# Change the quicknote format to get rid of the word "quicknote"
9-
QUICKNOTE_FORMAT="%Y-%m-%d"
9+
# QUICKNOTE_FORMAT="%Y-%m-%d"
1010

1111
# Set extension to plain txt instead of markdown
12-
NOTES_EXT="txt"
12+
#NOTES_EXT="txt"

install.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
3+
# This is an install script for notes
4+
5+
# Yay, Echo self documents! :D
6+
echo "Checking for root..."
7+
[ "$(whoami)" != "root" ] && exec sudo -- "$0" -s -- "$@"
8+
9+
# This has to be defined after root elevation or script will fail.
10+
function assertInstalled() {
11+
for var in "$@"; do
12+
if ! which $var &> /dev/null; then
13+
echo "$var is required but not installed, exiting."
14+
exit 1
15+
fi
16+
done
17+
}
18+
19+
# Make sure we have everything actually installed that we need to install this.
20+
echo "Checking for dependencies..."
21+
assertInstalled bash curl tar mktemp install make
22+
23+
# Variable Definitions go here.
24+
user_home=`eval echo ~$SUDO_USER`
25+
extract_dir=$(mktemp -d /tmp/notes.XXXXX)
26+
27+
echo "Downloading and extracting Notes from Repository..."
28+
curl -L https://api.github.com/repos/pimterry/notes/tarball/latest-release | tar -xzp -C $extract_dir --strip-components=1
29+
if [ "$1" != "uninstall" ]; then
30+
echo "Installing notes..."
31+
cd $extract_dir && make USERDIR=$user_home
32+
else
33+
echo "Uninstalling notes..."
34+
cd $extract_dir && make uninstall USERDIR=$user_home
35+
fi
36+
echo "Cleaning up..."
37+
rm -rf $extract_dir
38+
echo "All done."

notes.1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
.TH NOTES 1
2+
.SH NAME
3+
notes \ - Simple delightful note taking, with more unix and less lock-in.
4+
.SH SYNOPSIS
5+
.B notes
6+
\fICOMMAND\fR
7+
.SH DESCRIPTION
8+
.B notes
9+
is a simple command line tool that makes note taking simpler.
10+
When run without a command, the help screen will appear and will offer a brief
11+
description of availible commands.
12+
13+
\fBnotes\fR will run the default editor for your distribution when opening a
14+
note. You can set $EDITOR in your shell to override it.
15+
\fBnotes\fR uses a configuration file located at \fB~/.config/notes/config\fR.
16+
This file overrides any settings in your rc file.
17+
.SH COMMANDS
18+
.TP
19+
.BR new ", " n " " \fR[\fINAME\fR]
20+
Open your text editor with a new note, with given name.
21+
If no name is given, a quick note will be created with an auto-generated
22+
name.
23+
.TP
24+
.BR find ", " f " " \fR[\fIPATTERN\fR]
25+
Searches for notes using the given pattern, returning all matches. If no
26+
pattern is given, returns every note.
27+
.TP
28+
.BR grep ", " g " " \fIPATTERN\fR
29+
Searches the contents of all notes for the given pattern. Returns all matches.
30+
.TP
31+
.BR search ", " s " " \fIPATTERN\fR
32+
Combination of find and grep.
33+
.TP
34+
.BR ls " " \fR[\fIDIRECTORY\fR]
35+
Lists all notes within \fIDIRECTORY\fR. Lists contents of $NOTES_DIRECTORY if
36+
no path is provided.
37+
.TP
38+
.BR open ", " o
39+
Opens $NOTES_DIRECTORY in your file explorer.
40+
.TP
41+
.BR open ", " o " "\fINAME\fR
42+
Opens note \fINAME\fR using your configured editor. \fINAME\fR can either be an
43+
absolute path or relative to $NOTES_DIRECTORY.
44+
.TP
45+
.BR rm " "\fR[\fB\-r\fR | \fB\-\-recursive\fR] " "\fINAME\fR
46+
Removes \fINAME\fR. If \-r or \-\-recursive is given, folders will be removed.
47+
.SH AUTHORS
48+
Notes was created by Tim Perry, who is still the maintainer. Numerous
49+
contributions have been submitted via pull requests on github.
50+
<\fBhttp://github.com/pimterry/notes\fR>.
51+
52+
If you have a clone of notes.git, the output of \fBgit-shortlog\fR(1) and
53+
\fBgit-blame\fR(1) can show you the authors for specific parts of the project.
54+

0 commit comments

Comments
 (0)