Skip to content

Commit

Permalink
0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
a committed Nov 5, 2020
1 parent 2055d4e commit ff20270
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ hist-md # Markdown format shortcut
hist-txt # Text format shortcut
```
```
usage: hist-format [-h] [-f FORMAT] [-c COUNT] [-l] [--lines]
usage: hist-format [-h] [-f FORMAT] [-c COUNT] [-l] [-m] [--lines]
Format xonsh history to post it to Github or another page.
Expand All @@ -37,6 +37,7 @@ optional arguments:
Count of commands
-l, --show-commands-list
Show commands in distinct section.
-m, --min Make block minimized i.e. by adding <details> tag in Markdown.
--lines Add additional lines before and after.
```

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setuptools.setup(
name='xontrib-hist-format',
version='0.0.5',
version='0.0.6',
license='MIT',
author='anki-code',
author_email='no@no.no',
Expand Down
12 changes: 11 additions & 1 deletion xontrib/hist_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def _hist_format(args):
argp.add_argument('-f', '--format', default='md', help="Format: md, txt.")
argp.add_argument('-c', '--count', default=10, help="Count of commands")
argp.add_argument('-l', '--show-commands-list', action='store_true', help="Show commands in distinct section.")
argp.add_argument('-m', '--min', action='store_true', help="Make block minimized i.e. by adding <details> tag in Markdown.")
argp.add_argument('--lines', action='store_true', help="Add additional lines before and after.")
opt = argp.parse_args(args)

Expand All @@ -27,12 +28,17 @@ def _hist_format(args):
cmds_idx = []
for i in list(range(len(__xonsh__.history) - 1, -1, -1)):
h = __xonsh__.history[i]
if 'hist-format' in h.cmd or 'hist-md' in h.cmd:
if 'hist-format' in h.cmd or 'hist-md' in h.cmd or 'hist-txt' in h.cmd:
continue
if len(cmds_idx) >= opt.count or h.cmd.rstrip() == 'clear':
break
cmds_idx.append(i)

if opt.min:
if opt.format == 'md':
print()
print('<details>')

if opt.lines:
print()
print('-' * term_cols)
Expand Down Expand Up @@ -71,6 +77,10 @@ def _hist_format(args):
print()
print('-' * term_cols)

if opt.min:
if opt.format == 'md':
print()
print('</details>')

aliases['hist-format'] = _hist_format
aliases['hist-md'] = ['hist-format', '-f', 'md']
Expand Down

0 comments on commit ff20270

Please sign in to comment.