diff --git a/README.md b/README.md index af0b093..c65dd26 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Who is who in **bin** directory: - `c+ SYMBOL` comment selection (python: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`) - `c- SYMBOL` uncomment selection - `git+ MESSAGE` git: commit and push to master -- `h+` heading +- `h+ SYMBOL` draw a pretty heading - `hg+ MESSAGE` hg: commit and push to master - `lc+` to lowercase - `nobs+` taken from plan9 `nobs` (it removes all backspace characters and the characters that precede them) diff --git a/bin/h+ b/bin/h+ index 858d164..fa08307 100755 --- a/bin/h+ +++ b/bin/h+ @@ -1,32 +1,14 @@ -#!/usr/bin/env perl +#!/usr/bin/env bash -use strict; -use warnings; -use feature 'say'; -use utf8; -use open qw(:std :utf8); +symbols="$1" -my $symbol = '#'; -my $line = readline(STDIN) // ''; -chomp($line); +symbol=${symbols:0:1} -## add more comment symbols? -## now supported: -## '#' -- default for bash, perl, ... -## '%' -- erlang -## '/' -- js, c, ... -## ';' -- lisp -if ( - $line =~ m{ - ^([#%/;]) # line starts with comment symbol - \1* # symbol can be repeated - \s # first space separates symbol from content - (.+)$ # heading content - }x -) { - $symbol = $1; - $line = $2; -} +if [ ! "$symbol" ]; then + symbol='#' +fi -say $symbol x 2, ' ', uc $line; -print $symbol x 2, ' ', '-' x 77; +line=$(sed 1q | uc+) + +echo "$symbol$symbol $line" +echo "$symbol$symbol -----------------------------------------------------------------------------"