Code Monkey home page Code Monkey logo

typer's Introduction

Typer

Typing test in your terminal

Typer Banner

Installation

To just install typer simply use this command:

go install github.com/maaslalani/typer@latest

Usage

To begin a typing test simply type typer. This will generate random words for you to type and show you your WPM score.

typer

To change the length of the typing test, use the --length flag.

typer -l 20

To set min word length, you can use --min-word-length flag.

typer --min-word-length 5

There is no maximum value, but anything below 1 will count as no min length.

You can use Monkeytype as a source of words, just pass -m, --monkeytype flag, by default it'll use english dictionary, you can change that by adding --monkeytype-language string flag.

typer -m --monkeytype-language code_go

see: monkeytype/languages/_list.json

If you want to provide your own text, you can pass in a file name with the --file flag. The typing test will use the contents of the specified file.

typer -f filename.txt

You can also pipe data by stdin.

echo 'Text from stdin!' | typer

Themes

There is basic theme support, theme should be saved in config file (default $HOME/.typer.yaml) and should look similar to this default theme:

theme:
  #file: /an/absoulute/path/to/the/theme.yaml # if set, it will ignore everything below
  bar:
    color: '#4776E6' # basic color of the progressbar
    #gradient: '#ff0000' # if passed, will generate a gradient from previous color to this one
  graph:
    # see: https://pkg.go.dev/github.com/guptarohit/asciigraph#AnsiColor
    # see: https://github.com/guptarohit/asciigraph/blob/master/color.go#L152-L292
    color: blue # does not use rgb but rather ANSI codes
    height: 3   # height of the graph
  text:
    error: # color when misspelled
      background: '#f33'
      foreground: '#fff'
    typed: # color when character have been typed
      foreground: '#fff'
      #background: '#000' # optional, default theme does not add background
    untyped: # color when still haven't been typed
      foreground: '#555'
      #background: '#000' # optional, default theme does not add background

Demo

typer

typer's People

Contributors

happyrip avatar jphager2 avatar maaslalani avatar paarthmadan avatar robopuff avatar zrcoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

typer's Issues

Panics if /usr/share/dict/words not found

Describe the bug
Running with no args on arch linux I don't have the "words" package installed. I get a panic. Not a big deal and easily worked around but a clear error message or even a small fallback list of words baked into the exe might be more graceful.

To Reproduce
Steps to reproduce the behavior:
Install typer on arch linux without the "words" package. Run it with no arguments.

Expected behavior
Fall back to some other word list, or print a simple error message.

Screenshots

❯ typer
panic: open /usr/share/dict/words: no such file or directory

goroutine 1 [running]:
github.com/tjarratt/babble.readAvailableDictionary()
        /home/plyons/go/pkg/mod/github.com/tjarratt/[email protected]/babble_unix.go:14 +0x9c
github.com/tjarratt/babble.NewBabbler(...)
        /home/plyons/go/pkg/mod/github.com/tjarratt/[email protected]/babble.go:22
github.com/maaslalani/typer/pkg/utility.RandomWords(0x14)
        /home/plyons/go/pkg/mod/github.com/maaslalani/[email protected]/pkg/utility/utility.go:19 +0x6f
github.com/maaslalani/typer/pkg/typer.FromRandom(0xc000010010, 0x6f95c8)
        /home/plyons/go/pkg/mod/github.com/maaslalani/[email protected]/pkg/typer/typer.go:54 +0x1e
github.com/maaslalani/typer/cmd.glob..func1(0x94d660, {0x6f6873, 0x0, 0x0})
        /home/plyons/go/pkg/mod/github.com/maaslalani/[email protected]/cmd/root.go:58 +0x26b
github.com/spf13/cobra.(*Command).execute(0x94d660, {0xc000012200, 0x0, 0x0})
        /home/plyons/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0x94d660)
        /home/plyons/go/pkg/mod/github.com/spf13/[email protected]/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
        /home/plyons/go/pkg/mod/github.com/spf13/[email protected]/command.go:897
github.com/maaslalani/typer/cmd.Execute()
        /home/plyons/go/pkg/mod/github.com/maaslalani/[email protected]/cmd/root.go:68 +0x25
main.main()
        /home/plyons/go/pkg/mod/github.com/maaslalani/[email protected]/main.go:6 +0x17

Desktop (please complete the following information):

  • OS: arch linux

Additional context
Add any other context about the problem here.

Incorrect measurement of time

For now time is measured from the start of the program, I think to measure WPM correctly it should be measured from the first keystroke.

For now WPM is calculated using equation like this:

(model.Score / charsPerWord) / (time.Since(m.Start).Minutes())

Theme colors not working in Ansi256

Describe the bug
Text colors do not work as intended in Ansi256

To Reproduce
Steps to reproduce the behavior:

  1. Use Ansi256 Terminal (e.g. Mac terminal with Settings > Profile > Advanced > Declare terminal as: xterm-256color
  2. Configure colors in ~/.typer.yaml like:
theme:
  bar:
    color: '#555555'
  graph:
    color: purple
    height: 3
  text:
    error:
      foreground: '#FF00000'
      background: '#FFFFFF'
    typed:
      foreground: '#0000FF'
    untyped:
      foreground: '#555555'
  1. run typer

Expected behavior
The configured colors should be approximated for the terminal.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
I think that the termenv color profile should be used when setting the colors. Will make a PR for this. (Also termenv has had several version changes, and could be updated. Happy to do that if desired.)

Support special characters

Describe the bug
typer panics with umlauts

To Reproduce
Steps to reproduce the behavior:

  1. run echo "ä" | typer
  2. press any key

Desktop (please complete the following information):

  • OS: Manjaro Linux

Quote option

Is your feature request related to a problem? Please describe.
Quotations can be used from monkeytype repository using quotes folder instead of languages ​​folder

Describe the solution you'd like
The -q flag can be used with -m

Describe alternatives you've considered

Additional context
I'm planning to create a pr for this

Read text from `stdin` for typing test

Currently typer only allows random words that are generated to be used as the typing test. It would be really nice if a user could provide their own text from a file or piped in from another program.

Example:

curl https://www.random.text/lorem.txt | typer
cat random.txt | typer

scoop pakage

please provide a scoop package for typer .
at window 🙏

Prodive own UI

Is your feature request related to a problem? Please describe.
I want to use the business logic you have implemented but do not want to use it in the terminal. I want to build my own UI arround the logic

Describe the solution you'd like
I would like an Interface for UI Outputs which can be injected

Does anyone have some suggestions ? I did a quick code check and could not determine a clear seperation from business logic and UI representation. Am I wrong ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.