Skip to content

Commit 8c13697

Browse files
committed
Changes suggested by @pimterry
Signed-off-by: primis <[email protected]>
1 parent 7623326 commit 8c13697

File tree

4 files changed

+63
-13
lines changed

4 files changed

+63
-13
lines changed

Makefile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,29 @@ BASH_COMPLETION_DIR := $(shell pkg-config --variable=completionsdir bash-complet
44
BASH_COMPLETION_DIR := $(strip $(BASH_COMPLETION_DIR))
55
USERDIR ?= $(HOME)
66

7+
# The @ symbols make the output silent.
8+
# the \033[0m stuff is ansi color escape codes.
9+
710
install:
811
@if [ -d $(BASH_COMPLETION_DIR) ]; then \
9-
echo $(BASH_COMPLETION_DIR);\
10-
cp notes.bash_completion "$(BASH_COMPLETION_DIR)/notes";\
12+
cp notes.bash_completion "$(BASH_COMPLETION_DIR)/notes"; \
13+
else \
14+
echo "Bash Completion was not installed, because the directory was" \
15+
"not found. if you have bash completion installed, follow the" \
16+
"README (https://github.com/pimterry/notes#installing-bash-completion)" \
17+
"to manually install it."; \
1118
fi # Small test for bash completion support
12-
install -m755 -D notes $(PREFIX)/bin/notes
13-
install -m777 -D config.example $(USERDIR)/.config/notes/config.example
14-
install -D notes.1 $(PREFIX)/share/man/man1/notes.1
15-
mandb 1>/dev/null
19+
@install -m755 -D notes $(PREFIX)/bin/notes
20+
@install -m777 -D config $(USERDIR)/.config/notes/config
21+
@install -D notes.1 $(PREFIX)/share/man/man1/notes.1
22+
@mandb 1>/dev/nulli 2>&1 # Fail silently if we don't have a mandb
23+
@echo -e "Notes has been installed to \033[0;32m$(PREFIX)/bin/notes." \
24+
"\n\033[0mA configuration file has also been created at" \
25+
"\033[0;32m$(USERDIR)/.config/notes/config,\033[0m" \
26+
"which you can edit if you'd like to change the default settings." \
27+
"\nGet started now by running \033[0;32mnotes open my-new-note\033[0m" \
28+
"Or you can run \033[0;32mnotes help\033[0m for more info"
29+
1630
uninstall:
1731
rm -f $(PREFIX)/bin/notes
1832
rm -f $(PREFIX)/share/man/man1/notes.1

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,47 @@ 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+
The easy way is:
2425

2526
```bash
26-
curl https://cdn.rawgit.com/pimterry/notes/master/install.sh | bash
27+
curl https://rawgit.com/pimterry/notes/master/install.sh | bash
2728
```
29+
This will install `notes`, a default configuration, a man page, and bash completion if possible.
2830

29-
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+
The manual way is:
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/v0.2.0/notes > /usr/local/bin/notes && chmod +x /usr/local/bin/notes
37+
```
38+
39+
#### Installing Bash completion
40+
41+
`notes` includes bash autocompletion, to let you tab-complete commands and your note names. This requires Bash > 4.0 and [bash-completion](https://github.com/scop/bash-completion) to be installed - it's probably available from your friendly local package manager.
42+
43+
To enable completion for notes, copy the completion script into your bash completion directory, and it should be automatically loaded. The bash completion directory is `/usr/share/bash-completion/completions/` on a typical Debian install, or `/usr/local/etc/bash_completion.d/` on OSX with `bash-completion` from homebrew. You may be able to find your own bash completion directory by running the following command:
44+
45+
pkg-config --variable=completionsdir bash-completion
46+
47+
Installing the completions might be as follows:
48+
49+
```bash
50+
curl https://cdn.rawgit.com/pimterry/notes/v0.2.0/notes.bash_completion > /usr/share/bash-completion/completions/notes
51+
```
52+
53+
You'll need to open a new shell for this to take effect.
54+
55+
## What if I want to uninstall this?
56+
If you used the automated install script to install notes, you can uninstall it the same way by running:
57+
```bash
58+
export uninstall=1 && curl https://rawgit.com/pimterry/notes/master/install.sh | bash
59+
```
3060

3161
## How do I configure this?
3262

63+
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.
64+
3365
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.
3466

3567
There are also more complex options available. You can set any configuration properties either in the environment, or in a config file (stored in `~/.config/notes/config`), with settings in config overriding those in your environment. This allows you to configure a different `$EDITOR` for notes to everything else, if you like. The config file is a good choice for more complex set ups, but probably not worth worrying about to start with. We've included an example config in this repo for you ([config.example](config.example)) that you can copy if you like.

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ echo "Checking for Dependencies..."
2121

2222
# Variable Definitions go here.
2323
user_home=`eval echo ~$SUDO_USER`
24-
bash_completion_dir=`pkg-config --variable=completionsdir bash-completion 2>/dev/null`
2524
extract_dir=$(mktemp -d /tmp/notes.XXXXX)
2625

2726
echo "Downloading and Extracting Notes from Repository..."
2827
curl -L https://api.github.com/repos/pimterry/notes/tarball | tar -xzp -C $extract_dir --strip-components=1
29-
echo "Installing notes..."
28+
if [ "$uninstall" != "1" ]; then
29+
echo "Installing notes..."
3030
cd $extract_dir && make USERDIR=$user_home
31+
else
32+
echo "Uninstalling notes..."
33+
cd $extract_dir && make uninstall USERDIR=$user_home
34+
fi
3135
echo "Cleaning Up..."
3236
rm -rf $extract_dir
3337
echo "All done."

0 commit comments

Comments
 (0)