acme
This commit is contained in:
commit
c2271ba672
43 changed files with 886 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
*.DS_Store
|
||||
27
LICENSE
Normal file
27
LICENSE
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Copyright (c) 2017, Ev Bogdanov
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
189
README.md
Normal file
189
README.md
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
# Acme text editor
|
||||
|
||||

|
||||
|
||||
Acme is a Zen-style text editor.
|
||||
|
||||
Using Acme you sacrifice:
|
||||
- configuration files
|
||||
- themes
|
||||
- syntax highlighting
|
||||
- autocompletion
|
||||
- specific language support
|
||||
- *your favourite Vim/Emacs/Sublime feature* :trollface:
|
||||
|
||||
What you gain is that instead of spending too much time configuring your editor, you will focus on actual working.
|
||||
|
||||
The killer feature of Acme is how it integrates into surrounding system. Acme is not trying to be a complete environment by itself. Acme acts as a glue which links together other programs and tools. With Acme the OS becomes your IDE.
|
||||
|
||||
## Install
|
||||
|
||||
### FreeBSD
|
||||
```
|
||||
pkg install plan9port
|
||||
```
|
||||
|
||||
### macOS
|
||||
```
|
||||
brew install plan9port
|
||||
```
|
||||
|
||||
### Debian
|
||||
```
|
||||
sudo apt-get install gcc libx11-dev libxt-dev libxext-dev libfontconfig1-dev
|
||||
git clone https://github.com/9fans/plan9port $HOME/plan9
|
||||
cd $HOME/plan9/plan9port
|
||||
./INSTALL -r $HOME/plan9
|
||||
```
|
||||
|
||||
## Environment setup
|
||||
|
||||
### Bash
|
||||
```
|
||||
export PLAN9="/path/to/plan9port"
|
||||
export PATH="$PATH:$PLAN9/bin"
|
||||
```
|
||||
|
||||
### Tcsh
|
||||
```
|
||||
setenv PLAN9 /path/to/plan9port
|
||||
set path = ($path $PLAN9/bin)
|
||||
```
|
||||
|
||||
## Font
|
||||
|
||||
Run font server:
|
||||
```
|
||||
fontsrv
|
||||
```
|
||||
|
||||
In case it's not installed:
|
||||
```
|
||||
cd /path/to/plan9port/src/cmd/fontsrv/
|
||||
9 mk install
|
||||
```
|
||||
|
||||
Have a look at all available fonts:
|
||||
```
|
||||
9p ls font
|
||||
```
|
||||
|
||||
Try one of them:
|
||||
```
|
||||
acme -f /mnt/font/'Droid Sans Mono'/13a/font
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
I spawn Acme by running `a` script.
|
||||
|
||||
## Scripts
|
||||
|
||||
Who is who in **bin** directory:
|
||||
|
||||
- `+ EXP` lisp-style polish notation calculator; example: `+ '(+ 1 2 3)'`
|
||||
- `F`, `lne`, `lpe`, `ne`, `pe` perl one-liners shortcuts
|
||||
- `a` start Acme
|
||||
- `a+ SYMBOL` alignment (default is fat comma: `|a+ '=>'`, erlang proplist: `|a+ ' '`)
|
||||
- `c+ SYMBOL` add comment (perl: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`)
|
||||
- `c- SYMBOL` delete comment (perl/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)
|
||||
- `g+ WHAT` recursively grep current directory
|
||||
- `git+ MESSAGE` git: commit and push to master
|
||||
- `h+` transform line to heading
|
||||
- `hg+ MESSAGE` hg: commit and push to master
|
||||
- `html+` html boilerplate
|
||||
- `lc+` to lowercase
|
||||
- `nobs+` is taken from plan9 `nobs` (it removes all backspace characters and the characters that precede them)
|
||||
- `perl+` perl boilerplate (shebang, `use strict` etc)
|
||||
- `put+ BROWSER` regular `Put` plus reload active tab in browser: `ff` | `ch` | `sa`
|
||||
- `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**.
|
||||
|
||||
## Random notes
|
||||
|
||||
- `Edit =` find out the current line number
|
||||
- `:13` goto 13th line
|
||||
- `:0` goto file beginning
|
||||
- `:$` goto file end
|
||||
- `:0,$` or `:,` or `Edit ,` select the whole file
|
||||
- `:1,5` select lines 1..5
|
||||
- `Edit , d` clear window
|
||||
- `Edit , < echo hello world` replace window body with some text
|
||||
- `Edit , < erl -man maps` replace window body with erlang manual
|
||||
- `Edit , s/text/TEXT/g` or `Edit , | perl -pe 's/text/TEXT/g'` global replace
|
||||
- `$%` or `$samfile` current file name
|
||||
- `$winid` current window id
|
||||
- `echo some text | 9p write acme/$winid/body` append to the end of current window
|
||||
- keyboard shortcuts:
|
||||
- `ctrl-u` delete from cursor to start of line
|
||||
- `ctrl-w` delete word before the cursor
|
||||
- `ctrl-h` delete character before the cursor
|
||||
- `ctrl-a` move cursor to start of the line
|
||||
- `ctrl-e` move cursor to end of the line
|
||||
- `ctrl-i` tab
|
||||
- `ctrl-j` enter
|
||||
- `ctrl-f` filepath autocompletion
|
||||
- `fn-*left arrow*` go home (macOS)
|
||||
- `fn-*right arrow*` go end (macOS)
|
||||
- `:foobar` search forward
|
||||
- `:-/foobar` search backwards
|
||||
- press `esc` to select the last typed text
|
||||
- press `esc` again to delete any selected text
|
||||
- `Font` switch between fonts
|
||||
- `:/^hel` regexp match: lines starting with 'hel'
|
||||
- `:/lo\n/` regexp match: lines ending with 'lo'
|
||||
- `:/^b/,/^e/` regexp match: lines between starting with 'b' and starting with 'e'
|
||||
- `Dump` write the state of acme to the file
|
||||
- `Load` restore from the dump
|
||||
- `Edit , > perl` pipe window body through perl interpreter (better than `perl -e ...`)
|
||||
|
||||
## Sam commands
|
||||
|
||||
- `Edit +/hello/` search 'hello' forward
|
||||
- `Edit -/hello/` search 'hello' backward
|
||||
- `Edit , > wc -l` count lines in file
|
||||
- `Edit , | sort` sort lines
|
||||
- `Edit 3,5p` print lines 3..5 in new window
|
||||
- `Edit 3,5 |uc+` lines 3..5 upper cased
|
||||
- `Edit 3,5 s/HE/he/g` replace on 3..5 lines only
|
||||
- `Edit 2 d` delete second line
|
||||
- `Edit 2 a/new\n/` append text after 2nd line
|
||||
- `Edit 2 i/new\n/` insert text before 2nd line
|
||||
|
||||
## Cut / Copy selection to a file
|
||||
|
||||
- select some text
|
||||
- cut: `| sed '' > file.txt`
|
||||
- copy: `> sed '' > file.txt`
|
||||
- pipe selection to a file: `> awk '{ print(toupper($1)) }' | sort | nl > file.txt`
|
||||
|
||||
## Other Plan9 goodies
|
||||
|
||||
- `win` start shell in a new window
|
||||
- `page FILE` view graphics files
|
||||
- `web URL` open url in your browser
|
||||
|
||||
## Resources
|
||||
|
||||
- [Acme homepage](http://acme.cat-v.org/)
|
||||
- [A Tour of the Acme Editor](http://www.youtube.com/watch?v=dP1xVpMPn8M)
|
||||
- [Plan 9 Acme Intro](http://www.youtube.com/watch?v=dopu3ZtdCsg)
|
||||
- [On using Acme as a day-to-day text editor](http://jlouisramblings.blogspot.ru/2013/04/acme-as-editor_20.html)
|
||||
- [Let’s Try Acme](http://echosa.github.io/blog/categories/acme/)
|
||||
- [Plan 9 configuration](https://github.com/jlouis/plan9-setup)
|
||||
- [Extensibility in the Acme text editor](http://www.mostlymaths.net/2013/03/extensibility-programming-acme-text-editor.html)
|
||||
- [Plan 9 from User Space](https://github.com/9fans/plan9port)
|
||||
- [Community: 9fans](http://plan9.bell-labs.com/wiki/plan9/9fans/index.html)
|
||||
- [Google group: plan9port-dev](https://groups.google.com/forum/#forum/plan9port-dev)
|
||||
- [Plan 9 and FreeBSD](https://forums.freebsd.org/threads/rio.29736/)
|
||||
BIN
acme.png
Normal file
BIN
acme.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 425 KiB |
33
bin/+
Executable file
33
bin/+
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
|
||||
sub do_calc {
|
||||
my ($op, $acc, @args) = @_;
|
||||
for my $arg (@args) {
|
||||
$acc += $arg if $op eq '+';
|
||||
$acc -= $arg if $op eq '-';
|
||||
$acc *= $arg if $op eq '*';
|
||||
$acc /= $arg if $op eq '/';
|
||||
}
|
||||
return $acc;
|
||||
}
|
||||
|
||||
sub calc {
|
||||
my $exp = shift;
|
||||
die 'oops!' unless $exp =~ m/\(([\+-\/\*])([0-9 \.-]+)\)/;
|
||||
return do_calc($1, split ' ', $2);
|
||||
}
|
||||
|
||||
sub pn {
|
||||
my $exp = shift;
|
||||
my $old = $exp;
|
||||
$exp =~ s/(\([\+-\/\*] [0-9 \.-]+\))/calc($1)/eg;
|
||||
die "oops! i'm stuck" if $exp eq $old;
|
||||
return $exp if $exp =~ m/^[0-9 \.-]+$/;
|
||||
return pn($exp);
|
||||
}
|
||||
|
||||
say pn($ARGV[0]);
|
||||
15
bin/F
Executable file
15
bin/F
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
perl -C -Mutf8 -lanE "$1"
|
||||
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
if [[ -f "$2" ]]; then
|
||||
perl -C -Mutf8 -lanE "$1" "$2"
|
||||
else
|
||||
perl -C -Mutf8 -F''"$1"'' -lanE "$2"
|
||||
fi
|
||||
|
||||
elif [[ $# -eq 3 && -f "$3" ]]; then
|
||||
perl -C -Mutf8 -F''"$1"'' -lanE "$2" "$3"
|
||||
fi
|
||||
18
bin/a
Executable file
18
bin/a
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export SHELL="$PLAN9/bin/rc"
|
||||
export acmeshell="$PLAN9/bin/rc"
|
||||
export BROWSER=safari
|
||||
export tabstop=4
|
||||
export TERM=dumb
|
||||
export PAGER=nobs
|
||||
|
||||
if [ "$(pgrep plumber)" ]; then
|
||||
echo plumber is running
|
||||
else
|
||||
echo starting plumber
|
||||
plumber
|
||||
cat "$HOME/acme/plumbing" "$PLAN9/plumb/basic" | 9p write plumb/rules
|
||||
fi
|
||||
|
||||
acme -a -f /mnt/font/Menlo-Regular/12a/font $1
|
||||
38
bin/a+
Executable file
38
bin/a+
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/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;
|
||||
}
|
||||
10
bin/c+
Executable file
10
bin/c+
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
my ($symbol) = @ARGV;
|
||||
|
||||
# default: | c+ '#'
|
||||
$symbol = '#' unless $symbol;
|
||||
|
||||
while (<STDIN>) {
|
||||
print "$symbol$_";
|
||||
}
|
||||
12
bin/c-
Executable file
12
bin/c-
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
# default: 1 symbol comment: #, %
|
||||
# need ARGV for comments like this: //
|
||||
|
||||
my ($symbol) = @ARGV;
|
||||
|
||||
my $offset = $symbol ? length $symbol : 1;
|
||||
|
||||
while (<STDIN>) {
|
||||
print substr $_, $offset;
|
||||
}
|
||||
5
bin/cc+
Executable file
5
bin/cc+
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
while (<STDIN>) {
|
||||
print join "", map { ucfirst $_ } (split "_", $_);
|
||||
}
|
||||
7
bin/cc-
Executable file
7
bin/cc-
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/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
Executable file
5
bin/d
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/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
Executable file
9
bin/eman
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
echo 'gimme erlang module, pls'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
erl -man "$1" | nobs+
|
||||
21
bin/g+
Executable file
21
bin/g+
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
## VERY NICE: USE `g+` IN COMBO WITH MOUSE CHORD
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
## To search for literal text in the current directory:
|
||||
## 1. point at text with button 1 in any window
|
||||
## 2. release button 1
|
||||
## 3. execute `g+`, clicking button 1 while 2 is held down
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Cwd;
|
||||
|
||||
die "don't know what to grep" unless @ARGV;
|
||||
|
||||
my $what = join ' ', @ARGV;
|
||||
my $cwd = getcwd();
|
||||
my $result = `grep -nR '$what' $cwd`;
|
||||
|
||||
print $result;
|
||||
11
bin/git+
Executable file
11
bin/git+
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo where is my commit message, bro?
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git add -A
|
||||
git commit -m ''"$*"''
|
||||
git push -u origin master
|
||||
32
bin/h+
Executable file
32
bin/h+
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
use utf8;
|
||||
use open qw(:std :utf8);
|
||||
|
||||
my $symbol = '#';
|
||||
my $line = readline(STDIN) // '';
|
||||
chomp($line);
|
||||
|
||||
## 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;
|
||||
}
|
||||
|
||||
say $symbol x 2, ' ', uc $line;
|
||||
print $symbol x 2, ' ', '-' x 77;
|
||||
36
bin/hg+
Executable file
36
bin/hg+
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Cwd;
|
||||
|
||||
die 'please enter commit message' unless @ARGV;
|
||||
|
||||
my $msg = join ' ', @ARGV;
|
||||
|
||||
my $dir = getcwd();
|
||||
|
||||
system "hg --cwd $dir addremove";
|
||||
system "hg --cwd $dir commit -m '$msg'";
|
||||
system "hg --cwd $dir push";
|
||||
|
||||
my $hgrc = "$dir/.hg/hgrc";
|
||||
|
||||
open my $fh, '<', $hgrc
|
||||
or die "cannot open $hgrc: $!\n";
|
||||
|
||||
my $repository;
|
||||
|
||||
while (my $line = readline($fh)) {
|
||||
if ($line =~ m/^bb\.prefix = (.+)$/) {
|
||||
$repository = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close $fh;
|
||||
|
||||
if ($repository) {
|
||||
print "\nview commits:\n";
|
||||
print "$repository/commits/all\n";
|
||||
}
|
||||
16
bin/html+
Executable file
16
bin/html+
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cat << 'HTML'
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>title</title>
|
||||
<!-- <link rel="shortcut icon" href="/favicon.ico"> -->
|
||||
<!-- <link rel="stylesheet" href="style.css"> -->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
8
bin/lc+
Executable file
8
bin/lc+
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use utf8;
|
||||
use open qw(:std :utf8);
|
||||
|
||||
while (<>) {
|
||||
print lc $_;
|
||||
}
|
||||
3
bin/lne
Executable file
3
bin/lne
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -lnE "$@"
|
||||
3
bin/lpe
Executable file
3
bin/lpe
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -lpE "$@"
|
||||
3
bin/ne
Executable file
3
bin/ne
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -nE "$@"
|
||||
3
bin/nobs+
Executable file
3
bin/nobs+
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
sed 's/.//g' "$@"
|
||||
3
bin/pe
Executable file
3
bin/pe
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -pE "$@"
|
||||
19
bin/perl+
Executable file
19
bin/perl+
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
$template = <<'TMP';
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
use experimental 'signatures';
|
||||
|
||||
sub main {
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
TMP
|
||||
|
||||
print $template;
|
||||
72
bin/put+
Executable file
72
bin/put+
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#!/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'";
|
||||
10
bin/s-
Executable file
10
bin/s-
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
while (<>) {
|
||||
if ($_ =~ m/^\s+$/) {
|
||||
print "\n";
|
||||
} else {
|
||||
$_ =~ s/^\s+//;
|
||||
print $_;
|
||||
}
|
||||
}
|
||||
19
bin/s2t
Executable file
19
bin/s2t
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $N_SPACES = $ARGV[0] || 4;
|
||||
|
||||
while (my $line = <STDIN>) {
|
||||
# Skip empty lines
|
||||
print "\n" and next if $line !~ m/\S/;
|
||||
|
||||
$line =~ m/^(\s*)(.+)$/;
|
||||
my $n_spaces = length($1);
|
||||
my $n_tabs = ($n_spaces > 0 and $n_spaces < $N_SPACES)
|
||||
? 1
|
||||
: int($n_spaces / $N_SPACES);
|
||||
|
||||
print "\t" x $n_tabs . "$2\n";
|
||||
}
|
||||
5
bin/t+
Executable file
5
bin/t+
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
while (<>) {
|
||||
print "\t$_";
|
||||
}
|
||||
6
bin/t-
Executable file
6
bin/t-
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
while (<>) {
|
||||
$_ =~ s/^\t//;
|
||||
print $_;
|
||||
}
|
||||
17
bin/t2s
Executable file
17
bin/t2s
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $N_SPACES = $ARGV[0] || 4;
|
||||
|
||||
while (my $line = <STDIN>) {
|
||||
# Skip empty lines
|
||||
print "\n" and next if $line !~ m/\S/;
|
||||
|
||||
$line =~ m/^(\t*)(.+)$/;
|
||||
my $n_tabs = length($1);
|
||||
my $n_spaces = $n_tabs * $N_SPACES;
|
||||
|
||||
print ' ' x $n_spaces . "$2\n";
|
||||
}
|
||||
8
bin/uc+
Executable file
8
bin/uc+
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use utf8;
|
||||
use open qw(:std :utf8);
|
||||
|
||||
while (<>) {
|
||||
print uc $_;
|
||||
}
|
||||
63
bin/w+
Executable file
63
bin/w+
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/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();
|
||||
40
docs/9p.txt
Normal file
40
docs/9p.txt
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
# write works:
|
||||
echo очешуеть | 9p write acme/2/body
|
||||
|
||||
# read works:
|
||||
9p read acme/2/body
|
||||
...
|
||||
очешуеть
|
||||
|
||||
# ls
|
||||
9p ls acme
|
||||
9p ls plumb
|
||||
|
||||
# read current windows:
|
||||
9p read acme/index
|
||||
|
||||
# read default rules
|
||||
9p read plumb/rules
|
||||
|
||||
// // //
|
||||
|
||||
# write window body with $winid == 2 into another window
|
||||
Edit , < 9p read acme/2/body
|
||||
|
||||
# close window with $winid == 3
|
||||
echo del | 9p write acme/3/ctl
|
||||
|
||||
// // //
|
||||
|
||||
touch /Users/ev/Desktop/wtf2.txt
|
||||
|
||||
echo opanki >> /Users/ev/Desktop/wtf2.txt
|
||||
|
||||
echo 'name /Users/ev/Desktop/wtf2.txt' | 9p write acme/2/ctl
|
||||
echo clean | 9p write acme/2/ctl
|
||||
echo get | 9p write acme/2/ctl
|
||||
|
||||
// // //
|
||||
|
||||
echo 'текст в новом окне' | 9p write acme/new/body
|
||||
BIN
docs/RobPike_AcmeUserInterfaceForProgrammers.pdf
Normal file
BIN
docs/RobPike_AcmeUserInterfaceForProgrammers.pdf
Normal file
Binary file not shown.
BIN
docs/SamCommands.pdf
Normal file
BIN
docs/SamCommands.pdf
Normal file
Binary file not shown.
3
docs/erlang_unicode.txt
Normal file
3
docs/erlang_unicode.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
erl +pc unicode
|
||||
|
||||
io:setopts([{encoding, utf8}]).
|
||||
13
docs/music.txt
Normal file
13
docs/music.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
1. window:
|
||||
/path/to/legally/purchased/music
|
||||
|
||||
2. add tag:
|
||||
## play 10 seconds
|
||||
afplay -t 10
|
||||
|
||||
## play full song
|
||||
afplay
|
||||
|
||||
3. L-select song
|
||||
|
||||
4. M-hold + L-click
|
||||
19
docs/read_body_from_erlang.txt
Normal file
19
docs/read_body_from_erlang.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
## ACME WITH WINID == 7
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
каждый охотник желает знать где сидит фазан
|
||||
|
||||
|
||||
## ERLANG
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
erl +pc unicode
|
||||
|
||||
io:setopts([{encoding, unicode}]).
|
||||
|
||||
Winid = "7".
|
||||
|
||||
Body = os:cmd("9p read acme/" ++ Winid ++ "/body").
|
||||
|
||||
Body =:= "каждый охотник желает знать где сидит фазан".
|
||||
true
|
||||
24
docs/single_quote_in_perl_one_liner.txt
Normal file
24
docs/single_quote_in_perl_one_liner.txt
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
## IN
|
||||
## -----------------------------------------------------------------------------
|
||||
apple => 'apple.png',
|
||||
cherry_pie => 'cherry_pie.png',
|
||||
berries => 'berries.png',
|
||||
yummy_taco => 'yummy_taco.png',
|
||||
|
||||
## OUT
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
apple.png
|
||||
cherry_pie.png
|
||||
berries.png
|
||||
yummy_taco.png
|
||||
|
||||
## BASH
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
Edit , > lne '/'\''(.+)'\''/; say $1'
|
||||
|
||||
## RC
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
Edit , > lne '/''(.+)''/; say $1'
|
||||
38
docs/single_quote_rc_vs_sh.txt
Normal file
38
docs/single_quote_rc_vs_sh.txt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
## RC
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
echo $%
|
||||
/Users/ev/
|
||||
|
||||
echo ''''
|
||||
'
|
||||
|
||||
a '1
|
||||
bb '22
|
||||
ccc '333
|
||||
|
||||
|a+ ''''
|
||||
|
||||
a '1
|
||||
bb '22
|
||||
ccc '333
|
||||
|
||||
|
||||
## SH
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
echo $%
|
||||
$%
|
||||
|
||||
echo "'"
|
||||
'
|
||||
|
||||
a '1
|
||||
bb '22
|
||||
ccc '333
|
||||
|
||||
|a+ "'"
|
||||
|
||||
a '1
|
||||
bb '22
|
||||
ccc '333
|
||||
22
plumbing
Executable file
22
plumbing
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
## MUSIC GO TO AFPLAY
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
## mac only
|
||||
## todo: rewrite for freebsd / linux
|
||||
|
||||
kind is text
|
||||
data matches '[a-zA-Z¡-0-9_\-./]+'
|
||||
data matches '([a-zA-Z¡-0-9_\-./]+)\.(mp3|mp4|mpeg)'
|
||||
data isfile $0
|
||||
plumb start afplay $file
|
||||
|
||||
## PERL ERROR MESSAGES GO TO ACME
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
type is text
|
||||
data matches '([a-zA-Z¡-0-9_\-.]+\.p[l|m])( line )([0-9]+)?'
|
||||
arg isfile $1
|
||||
data set $file
|
||||
attr add addr=$3
|
||||
plumb to edit
|
||||
plumb client window $editor
|
||||
Loading…
Add table
Add a link
Reference in a new issue