Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ all:
install:
install -d $(DESTDIR)$(PREFIX)/bin
install -d $(DESTDIR)$(PREFIX)/share/man/man1
install -d $(DESTDIR)$(PREFIX)/share/tt
install -m755 bin/tt $(DESTDIR)$(PREFIX)/bin
install -m644 tt.1.gz $(DESTDIR)$(PREFIX)/share/man/man1
cp -r themes words quotes $(DESTDIR)$(PREFIX)/share/tt

.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/tt
rm -f $(DESTDIR)$(PREFIX)/share/man/man1/tt.1.gz
rm -rf $(DESTDIR)$(PREFIX)/share/tt

.PHONY: assets
assets:
python3 ./scripts/themegen.py
./scripts/pack themes/ words/ quotes/ > src/packed.go
./scripts/pack > src/packed.go
pandoc -s -t man -o - man.md|gzip > tt.1.gz

.PHONY: rel
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,19 @@ other *nix tools. With a little shell scripting most features the user can
conceive of should be possible to implement. Below are some simple examples of
what can be achieved.

- `shuf -n 40 /usr/share/dict/words|tt` Produces a test consisting of 40 random words drawn from your system's dictionary.
- `curl http://api.quotable.io/random|jq '[.text=.content|.attribution=.author]'|tt -quotes -` Produces a test consisting of a random quote.
- `shuf -n 40 /usr/share/dict/words | tt` Produces a test consisting of 40 random words drawn from your system's dictionary.
- `curl http://api.quotable.io/random | jq -M '[.text=.content|.attribution=.author]'|tt -quotes -` Produces a test consisting of a random quote.
- `alias ttd='tt -csv >> ~/wpm.csv'` Creates an alias called ttd which keeps a log of progress in your home directory`.
- `fortune matrix | tt -bold -blockcursor -showwpm -theme matrix -w "$[COLUMNS/2]"` Produces a test consisting of a random "The Matrix" quote.

The default behaviour is equivalent to `tt -n 50`.

See `-help` for an exhaustive list of options.

## Configuration

Custom themes and word lists can be defined in `~/.tt/themes` and `~/.tt/words`
Custom themes and word lists can be defined in `~/.config/tt/themes` and `~/.config/tt/words`
and used in conjunction with the `-theme` and `-words` flags. A list of
preloaded themes and word lists can be found in `words/` and `themes/` and are
accessible by default using the respective flags.

33 changes: 21 additions & 12 deletions man.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,43 +170,49 @@ tt ~/war_and_peace.txt -start 1
Produces a test consisting of 40 random words draw from
the system dictionary (similar to 'tt -n 40').
```
shuf -n 40 /usr/share/dict/words|tt
shuf -n 40 /usr/share/dict/words | tt
```

Starts a test consisting of two randomly drawn quotes from api.quotable.io and
prints the output of each test to STDOUT in csv format.
```
curl https://api.quotable.io/quotes|\
jq '[.results[]|.text=.content|.attribution=.author][:2]'|\
tt -quotes - -norreport -csv
curl -L api.quotable.io/quotes \
| jq -M '[.results[]|.text=.content|.attribution=.author][:2]' \
| tt -quotes - -norreport -csv
```

Starts a test consisting of a randomly drawn quote from "The Matrix" movies.
```
fortune matrix | tt -bold -showwpm -theme matrix -w "$[COLUMNS/2]"
```

Starts a new typing test which uses the tt source as input:

```
curl -LsS https://raw.githubusercontent.com/lemnos/tt/master/src/tt.go | head -n 20 | tt -noskip -raw
curl -L raw.githubusercontent.com/lemnos/tt/master/src/tt.go \
| head -n 20 | tt -noskip -raw
```

Modify to taste.

# PATHS

Some options like **-words** and **-theme** accept a path. If the given path does
not exist, the following directories are searched for a file with the given
name before falling back to internal resources:

~/.tt/words\
~/.tt/themes\
/etc/tt/words\
/etc/tt/themes
~/.config/tt/words/\
~/.config/tt/themes/\
/usr/local/tt/words/\
/usr/local/tt/themes/\
/etc/tt/words/\
/etc/tt/themes/\

# KEYS

**esc: ** Restarts the test\
**C-c: ** Terminates tt\
**C-backspace: ** Deletes the previous word\
**right** Move to the next test.\
**left** Move to the previous test.
**left** Move to the previous test.\

# AUTHOR

Expand All @@ -215,9 +221,12 @@ Aetnaeus (aetnaeus@protonmail.com)
# SEE ALSO

## Project Page
https://github.com/dardo82/tt

Originally forked from
https://github.com/lemnos/tt

# LICENSE

MIT

14 changes: 7 additions & 7 deletions scripts/pack
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh

[ $# -gt 0 ] || { echo "Usage: $0 <path>... > packed.go"; exit 1; }

cat <<!
package main

Expand All @@ -22,9 +20,11 @@ func readPackedFile(path string) []byte {
!

printf "var packedFiles = map[string]string{\n"
find "$@" -type f|while read f; do
printf "\t\"$f\": \""
openssl base64 -A < "$f"
printf "\",\n"
done
if [ $# -gt 0 ]; then
find "$@" -type f|while read f; do
printf "\t\"$f\": \""
openssl base64 -A < "$f"
printf "\",\n"
done
fi
printf "}"
Loading