Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nbedos committed Jul 8, 2018
2 parents 3a401f3 + 502a31d commit 464f5ea
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
15 changes: 10 additions & 5 deletions README.md
Expand Up @@ -5,10 +5,10 @@ A Linux terminal recorder written in Python that renders your command
line sessions as standalone SVG animations.

<p align="center">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.3.0/examples/awesome.svg">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.4.0/examples/awesome.svg">
</p>

More examples of recordings can be found [here](https://github.com/nbedos/termtosvg/blob/0.3.0/examples/examples.md)
More examples of recordings can be found [here](https://github.com/nbedos/termtosvg/blob/0.4.0/examples/examples.md)

## Motivation
I really like the clean look of SVG animations. I wanted to see
Expand Down Expand Up @@ -119,12 +119,17 @@ color15 = #ffffff

Color themes can freely be added, removed or modified. Once a color theme
has been added to the configuration it can be referred to in the global
section of the configuration, or be used at the command line as a parameter
to the `--theme` flag.
section of the configuration file, or be used at the command line as a
parameter to the `--theme` flag.

Definitions for the foreground and background colors and for color0 to
color7 are mandatory. If color8 through color15 (bright ANSI colors) are
defined, they are used by termtosvg to display bold characters as a
replacement for color0 through color7.

## Dependencies
termtosvg uses:
* [pyte](https://github.com/selectel/pyte) to render the terminal screen
* [svgwrite](https://github.com/mozman/svgwrite) to create SVG animations
* [base16-xresources](https://github.com/chriskempson/base16-xresources) for default color themes
* [rawgit](https://rawgit.com/) for SVG animation hosting (see also [rawgit on GitHub](https://github.com/rgrove/rawgit))
* [rawgit](https://rawgit.com/) for hosting SVG animations displayed here on GitHub [rawgit on GitHub](https://github.com/rgrove/rawgit))
10 changes: 5 additions & 5 deletions examples/examples.md
@@ -1,25 +1,25 @@
# Examples
## awesome.svg
<p align="center">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.3.0/examples/awesome.svg">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.4.0/examples/awesome.svg">
</p>

## colors.svg
<p align="center">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.3.0/examples/colors.svg">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.4.0/examples/colors.svg">
</p>

## ipython.svg
<p align="center">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.3.0/examples/ipython.svg">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.4.0/examples/ipython.svg">
</p>

## htop.svg
<p align="center">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.3.0/examples/htop.svg">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.4.0/examples/htop.svg">
</p>

## unittest.svg
<p align="center">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.3.0/examples/unittest.svg">
<img src="https://cdn.rawgit.com/nbedos/termtosvg/0.4.0/examples/unittest.svg">
</p>
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -4,7 +4,9 @@

setup(
name='termtosvg',
version='0.3.0',
version='0.4.0',
licence='BSD 3-clause license',
author='Nicolas Bedos',
description='Record terminal sessions as SVG animations',
long_description='A Linux terminal recorder written in Python '
'which renders your command line sessions as '
Expand Down
13 changes: 8 additions & 5 deletions termtosvg/config.py
Expand Up @@ -64,7 +64,7 @@ def conf_to_dict(configuration):
"""Read a configuration string in INI format and return a dictionary
Raise a subclass of configparser.Error if parsing the configuration string fails
Raise ValueError if the color theme is invalid
Raise AsciiCastError if the color theme is invalid
"""
parser = configparser.ConfigParser(dict_type=CaseInsensitiveDict,
comment_prefixes=(';',))
Expand All @@ -78,13 +78,16 @@ def conf_to_dict(configuration):

themes = [theme.lower() for theme in parser.sections() if theme.lower() != 'global']
for theme_name in themes:
fg = parser.get(theme_name, 'foreground', fallback='')
bg = parser.get(theme_name, 'background', fallback='')
fg = parser.get(theme_name, 'foreground', fallback=None)
bg = parser.get(theme_name, 'background', fallback=None)
palette = ':'.join(parser.get(theme_name, 'color{}'.format(i), fallback='')
for i in range(16))

# This line raises AsciicastError if the color theme is invalid
config_dict[theme_name] = asciicast.AsciiCastV2Theme(fg, bg, palette)
try:
config_dict[theme_name] = asciicast.AsciiCastV2Theme(fg, bg, palette)
except asciicast.AsciiCastError:
logger.error('Failed parsing color theme "{}"'.format(theme_name))
raise

return config_dict

Expand Down
20 changes: 17 additions & 3 deletions termtosvg/data/termtosvg.ini
Expand Up @@ -23,7 +23,7 @@
; --help'

font = DejaVu Sans Mono
theme = solarized-dark
theme = gjm8


; All sections other than 'GLOBAL' define a color theme. You can add, delete
Expand All @@ -37,13 +37,27 @@ theme = solarized-dark
; magenta, cyan, white)
;
; If color8 through color15 (bright ANSI colors) are defined, they are used by
; termtosvg, otherwise color0 through color7 are used as a replacement
; termtosvg to display bold characters as a replacement for color0 through
; color7.
;
; All color values must be in #rrggbb format
;
; Default colors themes come from the base16-xresources projet
; Default color themes come mostly from the base16-xresources projet
; https://github.com/chriskempson/base16-xresources

[gjm8]
; Source: https://terminal.sexy/
foreground = #c5c5c5
background = #1c1c1c
color0 = #1c1c1c
color1 = #ff005b
color2 = #cee318
color3 = #ffe755
color4 = #048ac7
color5 = #833c9f
color6 = #0ac1cd
color7 = #e5e5e5

[circus]
; Authors: Stephan Boyer (https://github.com/stepchowfun) and Esther Wang
foreground = #a7a7a7
Expand Down

0 comments on commit 464f5ea

Please sign in to comment.