Rewrite commenting scripts

This commit is contained in:
Ev Bogdanov 2017-08-16 14:57:04 +03:00
parent a56f7ba603
commit 7046de9503
3 changed files with 14 additions and 18 deletions

View file

@ -82,8 +82,8 @@ I spawn Acme by running `a` script.
Who is who in **bin** directory:
- `a` start Acme
- `c+ SYMBOL` add comment (python: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`)
- `c- SYMBOL` delete comment (python/erlang: `|c-`, js: `|c- //`)
- `c+ SYMBOL` comment selection (python: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`)
- `c- SYMBOL` uncomment selection
- `g+ WHAT` recursively grep current directory
- `git+ MESSAGE` git: commit and push to master
- `h+` heading

13
bin/c+
View file

@ -1,10 +1,9 @@
#!/usr/bin/env perl
#!/usr/bin/env bash
my ($symbol) = @ARGV;
symbol="$1"
# default: | c+ '#'
$symbol = '#' unless $symbol;
if [ ! "$symbol" ]; then
symbol='#'
fi
while (<STDIN>) {
print "$symbol$_";
}
sed "s!^!$symbol!"

15
bin/c-
View file

@ -1,12 +1,9 @@
#!/usr/bin/env perl
#!/usr/bin/env bash
# default: 1 symbol comment: #, %
# need ARGV for comments like this: //
symbol="$1"
my ($symbol) = @ARGV;
if [ ! "$symbol" ]; then
symbol='#'
fi
my $offset = $symbol ? length $symbol : 1;
while (<STDIN>) {
print substr $_, $offset;
}
sed "s!^\($symbol\)*!!"