Delete a bunch of scripts
This commit is contained in:
parent
3aa6845583
commit
f2cdfeba2b
9 changed files with 3 additions and 257 deletions
14
README.md
14
README.md
|
|
@ -82,30 +82,22 @@ I spawn Acme by running `a` script.
|
|||
Who is who in **bin** directory:
|
||||
|
||||
- `a` start Acme
|
||||
- `a+ SYMBOL` alignment (default is fat comma: `|a+ '=>'`, erlang proplist: `|a+ ' '`)
|
||||
- `c+ SYMBOL` add comment (python: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`)
|
||||
- `c- SYMBOL` delete comment (python/erlang: `|c-`, js: `|c- //`)
|
||||
- `cc+` snake_case to CamelCase
|
||||
- `cc-` CamelCase to snake_case
|
||||
- `d` works like `Edit , d`
|
||||
- `eman MODULE` shortcut for `erl -man MODULE` (displays the manual page for the Erlang module MODULE)
|
||||
- `erun MODULE ARG1 ... ARGN` erlangish `go run`
|
||||
- `g+ WHAT` recursively grep current directory
|
||||
- `git+ MESSAGE` git: commit and push to master
|
||||
- `h+` transform line to heading
|
||||
- `h+` heading
|
||||
- `hg+ MESSAGE` hg: commit and push to master
|
||||
- `lc+` to lowercase
|
||||
- `nobs+` is taken from plan9 `nobs` (it removes all backspace characters and the characters that precede them)
|
||||
- `put+ BROWSER` regular `Put` plus reload active tab in browser: `ff` | `ch` | `sa`
|
||||
- `nobs+` taken from plan9 `nobs` (it removes all backspace characters and the characters that precede them)
|
||||
- `s-` remove leading whitespace
|
||||
- `s2t N_SPACES` spaces to tabs (default: 4 spaces to 1 tab)
|
||||
- `t2s N_SPACES` tabs to spaces (default: 1 tab to 4 spaces)
|
||||
- `t+` add tab
|
||||
- `t-` delete tab
|
||||
- `uc+` to uppercase
|
||||
- `w+ WIDTH` (hello, `fmt -w WIDTH`)
|
||||
|
||||
Put these guys in your **$path**.
|
||||
Put these guys in your **$PATH**.
|
||||
|
||||
## Random notes
|
||||
|
||||
|
|
|
|||
38
bin/a+
38
bin/a+
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use open qw(:std :utf8);
|
||||
|
||||
my ($d) = @ARGV;
|
||||
$d = "=>" unless $d;
|
||||
|
||||
my $max = 0;
|
||||
my @ls = ();
|
||||
my @rs = ();
|
||||
my $i = 1;
|
||||
my $t = "";
|
||||
|
||||
while (<STDIN>) {
|
||||
if ($i == 1) {
|
||||
$t = $1 if /^(\s+)/;
|
||||
$i += 1;
|
||||
}
|
||||
$_ =~ s/^\s+|\s+$//g;
|
||||
my @ls_rs = split $d, $_, 2;
|
||||
my $len = length $ls_rs[0];
|
||||
$max = $len if $len > $max;
|
||||
push @ls, $ls_rs[0];
|
||||
push @rs, $ls_rs[1];
|
||||
}
|
||||
|
||||
for (my $i = 0; $i < @ls; $i += 1) {
|
||||
my $l = $ls[$i];
|
||||
my $r = $rs[$i];
|
||||
my $n = $max - length $l;
|
||||
my $s = " " x $n;
|
||||
$l .= $s;
|
||||
print $t, $l, $d, $r;
|
||||
print "\n" unless $i + 1 == @ls;
|
||||
}
|
||||
5
bin/cc+
5
bin/cc+
|
|
@ -1,5 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
while (<STDIN>) {
|
||||
print join "", map { ucfirst $_ } (split "_", $_);
|
||||
}
|
||||
7
bin/cc-
7
bin/cc-
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
while (<STDIN>) {
|
||||
s/([A-Z]+)([A-Z][a-z])/$1_$2/g;
|
||||
s/([a-z\d])([A-Z])/$1_$2/g;
|
||||
print lc;
|
||||
}
|
||||
5
bin/d
5
bin/d
|
|
@ -1,5 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
open FH, "| 9p write acme/$ENV{winid}/addr";
|
||||
print FH ",";
|
||||
system "9p write acme/$ENV{winid}/data </dev/null";
|
||||
9
bin/eman
9
bin/eman
|
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
echo 'gimme erlang module, pls'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
erl -man "$1" | nobs+
|
||||
47
bin/erun
47
bin/erun
|
|
@ -1,47 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo 'Usage: erun mod.erl arg1 arg2 ...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## FILE WITH SOURCE CODE
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
file="$1"
|
||||
if [ ! -f "$file" ]; then
|
||||
echo 'File not found'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## ERLANG MODULE TO RUN
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
mod=$(echo $file | sed -e 's/.erl//')
|
||||
|
||||
## ARGUMENTS TO PASS TO THE MODULE
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
shift
|
||||
args="$@"
|
||||
if [ ! "$args" ]; then
|
||||
# Without arguments main/0 will be called. Force main/1
|
||||
args="''"
|
||||
fi
|
||||
|
||||
## COMPILE AND RUN
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
erlc $file
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Module should implement main/1 function
|
||||
erl -noshell +pc unicode -run $mod main $args -s init stop
|
||||
|
||||
## CLEAN UP
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
rm "$mod.beam"
|
||||
72
bin/put+
72
bin/put+
|
|
@ -1,72 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
## USAGE
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
## firefox:
|
||||
## put+ ff
|
||||
## chrome:
|
||||
## put+ ch
|
||||
## safari:
|
||||
## put+ sa
|
||||
|
||||
## DATA
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
use constant FIREFOX => 'ff';
|
||||
use constant CHROME => 'ch';
|
||||
use constant SAFARI => 'sa';
|
||||
|
||||
my $browser = $ARGV[0] || CHROME;
|
||||
my $osascript;
|
||||
|
||||
## ACME 'Put'
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
open my $fh, "| 9p write acme/$ENV{winid}/ctl";
|
||||
print $fh "put\n";
|
||||
close $fh;
|
||||
|
||||
## FIREFOX SCRIPT (SADLY, IT'S FULL OF BUGS)
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
if ($browser eq FIREFOX) {
|
||||
$osascript = 'tell application "Firefox"
|
||||
activate
|
||||
delay 2
|
||||
tell application "System Events"
|
||||
keystroke "r" using command down
|
||||
end tell
|
||||
end tell';
|
||||
}
|
||||
|
||||
## CHROME SCRIPT
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
if ($browser eq CHROME) {
|
||||
## wait for server update
|
||||
sleep 2;
|
||||
|
||||
$osascript = 'tell application "Google Chrome" to reload active tab of window 1';
|
||||
}
|
||||
|
||||
## SAFARI SCRIPT
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
if ($browser eq SAFARI) {
|
||||
## also wait for server update
|
||||
sleep 2;
|
||||
|
||||
$osascript = 'tell application "Safari"
|
||||
set docUrl to URL of document 1
|
||||
set URL of document 1 to docUrl
|
||||
end tell';
|
||||
}
|
||||
|
||||
## RUN SCRIPT
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
system "osascript -e '$osascript'";
|
||||
63
bin/w+
63
bin/w+
|
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
use utf8;
|
||||
use open qw(:std :utf8);
|
||||
|
||||
my $WIDTH_DEFAULT = 80;
|
||||
my $WIDTH = $ARGV[0] || $WIDTH_DEFAULT;
|
||||
|
||||
sub main {
|
||||
my $buf = '';
|
||||
while (my $line = <STDIN>) {
|
||||
if ($line =~ /^\s+$/) {
|
||||
say $buf;
|
||||
say '' if ($buf);
|
||||
$buf = '';
|
||||
next;
|
||||
}
|
||||
if ($buf) {
|
||||
$line = $buf . $line;
|
||||
}
|
||||
my ($head, $tail) = handle_str($line);
|
||||
say $head;
|
||||
$buf = handle_buf($tail);
|
||||
}
|
||||
say $buf if $buf;
|
||||
}
|
||||
|
||||
sub handle_buf {
|
||||
my $buf = shift;
|
||||
my $len = length($buf);
|
||||
if ($len == $WIDTH) {
|
||||
say $buf;
|
||||
return '';
|
||||
}
|
||||
if ($len < $WIDTH) {
|
||||
return $buf;
|
||||
}
|
||||
## $len > $WIDTH
|
||||
my ($head, $tail) = handle_str($buf);
|
||||
say $head;
|
||||
handle_buf($tail);
|
||||
}
|
||||
|
||||
sub handle_str {
|
||||
my $str = shift;
|
||||
if ($str =~ m/^(.{0,$WIDTH})\s(.*)$/) {
|
||||
return ($1, $2);
|
||||
}
|
||||
## no spaces here: 0..$WIDTH
|
||||
if ($str =~ m/^(\S*)\s(.*)$/) {
|
||||
return ($1, $2);
|
||||
}
|
||||
## no whitespace at all
|
||||
if ($str =~ m/^(\S+)$/) {
|
||||
return ($1, '');
|
||||
}
|
||||
die "ooops!";
|
||||
}
|
||||
|
||||
main();
|
||||
Loading…
Add table
Add a link
Reference in a new issue