├── LICENSE ├── README.md ├── bin ├── a+ ├── a- ├── acme.rc ├── chk ├── cl ├── crlf ├── erlfmt ├── erlpp ├── ff ├── g ├── gg ├── long ├── mouse ├── nocr ├── q ├── racme.rc ├── rmouse ├── rsam.rc ├── sam.rc └── winclear ├── lib └── plumbing └── skel ├── x.app.src ├── x_app.erl ├── x_srv.erl └── x_sup.erl /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | Copyright (c) 2012-2013 Jesper Louis Andersen. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Plan 9 from User space configuration 2 | 3 | This repository contains some configuration I did for Plan9 from user space. A quick list of what 4 | is in here is: 5 | 6 | * The `gg` command, which is a shorthand `git grep -n` helper for use with acme 7 | * The `a+` and `a-` commands which does indentation. 8 | * The `nocr` command which kills CR 9 | * The `q` command which quotes a selection 10 | * The `acme-start.rc` helper for spawning acme 11 | * The `erlfmt` command which nicely formats Erlang terms (Produces UTF-8 output) 12 | 13 | Furthermore plumbing rules for: 14 | 15 | * Ocaml - I did some ocaml work so it is nice to be able to jump to error messages when they 16 | occur in your codes. 17 | 18 | # Other setup things 19 | 20 | I make use of some Go packages: 21 | 22 | go get github.com/eaburns/E2 23 | go get github.com/eaburns/Watch 24 | go get 9fans.net/go/acme/acmego 25 | 26 | # This one is bound to move soon 27 | go get code.google.com/p/rsc/cmd/jfmt 28 | 29 | These are quite important for the correct operation. E2 is a better version of the E command. Watch can watch a subdirectory for file changes. The `jfmt` command can reformat JSON data. And acmego uses the (new) 'log' feature of acme to make sure things are formatted nicely when working with go code. 30 | 31 | I add the following to my `.profile`: 32 | 33 | # Plumb files instead of starting new editor. 34 | EDITOR=E 35 | unset FCEDIT VISUAL 36 | 37 | This sets up the editor to be the `E` command. It checks every second if the file has 38 | a change according to `ls -l` and lets you use acme as the editor when editing stuff. 39 | I use that a lot with `git(1)` so commits can be kept inside acme. 40 | 41 | # Get rid of backspace characters in Unix man output. 42 | PAGER=nobs 43 | 44 | I kill less as a default pager. This allows me to just scroll in the acme window rather 45 | than ending up with a mess. `nobs` removes certain control characters so the formatting 46 | is better. 47 | 48 | -------------------------------------------------------------------------------- /bin/a+: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | if(~ $#* 0){ 3 | * = ' ' # tab 4 | } 5 | 9 sed 's☺^☺'^$1^☺ 6 | -------------------------------------------------------------------------------- /bin/a-: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | if(~ $#* 0){ 3 | * = ' ' 4 | } 5 | 9 sed 's☺^'^$1^'☺☺' 6 | -------------------------------------------------------------------------------- /bin/acme.rc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | TERM=dumb 4 | plumber 5 | 6 | fn cd { builtin cd $1 && awd $sysname } 7 | tabstop=4 8 | 9 | #font='/mnt/font/Lucida Grande/15a/font' 10 | font='/mnt/font/Roboto Regular/14a/font' 11 | #font='/mnt/font/Noto Sans/13a/font' 12 | 13 | lfont='/mnt/font/Source Code Pro/14a/font' 14 | 15 | SHELL=rc 16 | exec acme -a -f $font -F $lfont $* 17 | 18 | -------------------------------------------------------------------------------- /bin/chk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | if(~ $#* 0) 4 | grep -v '^[^'']*(''[^'']*''[^'']*)*$' $* 5 | if not 6 | grep -nv '^[^'']*(''[^'']*''[^'']*)*$' $* /dev/null 7 | -------------------------------------------------------------------------------- /bin/cl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | if(~ $#TMPDIR 0) 4 | TMPDIR=/tmp 5 | tmp=$TMPDIR/ssam.tmp.$USER.$pid 6 | cat $* >$tmp 7 | 8 | { 9 | # select entire file 10 | echo ',{' 11 | echo k 12 | echo '}' 13 | echo 0k 14 | 15 | # Excess whitespace 16 | echo ', x/[ ]+$/ d' 17 | echo ', s/\n\n\n+/\n\n/g' 18 | } | sam -d $tmp >[2]/dev/null 19 | 20 | rm -f $tmp 21 | -------------------------------------------------------------------------------- /bin/crlf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | cat $* | sed 's/(^|[^ ])$/& /g' 4 | -------------------------------------------------------------------------------- /bin/erlfmt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cat | 9 sed \ 4 | -e "s/\.\.\./'...'/g" \ 5 | -e "s/(<[0-9]+\.[0-9]+\.[0-9]+>)/'\1'/g" \ 6 | -e "s/(#Port<[0-9]+.[0-9]+>)/'\1'/g" \ 7 | -e "s/(#Ref<([0-9]+\.)+[0-9]+>)/'\1'/g" \ 8 | | erlpp \ 9 | | 9 sed \ 10 | -e "s/'\.\.\.'/…/g" \ 11 | -e "s/<>/»/g" 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /bin/erlpp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env escript 2 | 3 | main([]) -> 4 | Data = fetch_until_eof(), 5 | format(Data). 6 | 7 | fetch_until_eof() -> 8 | add_dot(lists:concat(loop_io_input())). 9 | 10 | add_dot(L) -> 11 | Rev = lists:reverse(L), 12 | case strip(Rev) of 13 | [$. | _] = R -> R; 14 | R when is_list(R) -> lists:reverse([$. | Rev]) 15 | end. 16 | 17 | strip([$\n | R]) -> strip(R); 18 | strip(O) -> O. 19 | 20 | loop_io_input() -> 21 | case io:get_line("") of 22 | eof -> []; 23 | Data when is_list(Data) -> [Data | loop_io_input()] 24 | end. 25 | 26 | format(Data) -> 27 | {ok, Toks, _} = erl_scan:string(Data), 28 | {ok, Parse} = erl_parse:parse_term(Toks), 29 | io:format("~p~n", [Parse]). 30 | -------------------------------------------------------------------------------- /bin/ff: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find . -name "$@" 4 | 5 | -------------------------------------------------------------------------------- /bin/g: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | flags=() 4 | while(! ~ $#* 1 && ~ $1 -*) {flags=($flags $1); shift} 5 | if(~ $#* 1) {grep -n $flags -- $1 *.[Cbchm] /dev/null} 6 | if not grep -n $flags $* /dev/null 7 | -------------------------------------------------------------------------------- /bin/gg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git grep -n "$@" 4 | 5 | -------------------------------------------------------------------------------- /bin/long: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | cat $* | pr -t -e8 | awk 'length($0) > 80 { print NR ": " $0 }' 4 | -------------------------------------------------------------------------------- /bin/mouse: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # First, reset the pointer so it runs on the default setting. This undoes whatever the window manager 4 | # has decided to mistakenly setup. 5 | xset m default 6 | 7 | # Select the mouse we are going to adjust settings for 8 | 9 | MOUSE='pointer:Razer Razer Abyssus 1800' 10 | 11 | # The Abyssus runs an 1800 CPI resolution sensor. Decelerate it to around 1000 CPI, in order to 12 | # match the Kinzu V3 13 | xinput set-prop "$MOUSE" "Device Accel Constant Deceleration" 1.5 14 | 15 | # Accel profile (2 = polynomial) — Pick a polynomial accel curve on which to place accel parameters. 16 | # If the pointer is precise, the polynomial curve is easier to control than a standard linear curve. So 17 | # by picking this curve, things end up being somewhat easier to work with. 18 | xinput set-prop "$MOUSE" "Device Accel Profile" 2 19 | 20 | # Velocity Scaling factor — Lower values means less accel kick in. 21 | # For the polynomial curve, and a fast 1800 CPI mouse, you don't need a whole lot here for things 22 | # to kick in. The modest setting is this 23 | xinput set-prop "$MOUSE" "Device Accel Velocity Scaling" 0.20 24 | 25 | # Adaptive Deceleration is set last. While the above settings all has to do with pointer speed, 26 | # this setting then controls the precision of the pointer. Values greater than 1.0 means we allow 27 | # the input system to decelerate the mouse by this extra factor. 28 | xinput set-prop "$MOUSE" "Device Accel Adaptive Deceleration" 1.3 29 | -------------------------------------------------------------------------------- /bin/nocr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | cat $* | sed 's/ //g' 4 | -------------------------------------------------------------------------------- /bin/q: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | if(~ $#* 0) 4 | what=' ' 5 | if not { 6 | what=$1 7 | shift 8 | } 9 | 10 | sed 's/^/'$what' /' $* 11 | -------------------------------------------------------------------------------- /bin/racme.rc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | TERM=dumb 4 | plumber 5 | 6 | fn cd { builtin cd $1 && awd $sysname } 7 | tabstop=4 8 | 9 | #font='/mnt/font/Lucida Grande/12a/font' 10 | font='/mnt/font/Roboto Regular/12a/font' 11 | 12 | lfont='/mnt/font/Source Code Pro/12a/font' 13 | 14 | SHELL=rc 15 | exec acme -a -f $font -F $lfont $* 16 | 17 | -------------------------------------------------------------------------------- /bin/rmouse: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | xset m default 4 | 5 | MOUSE='SteelSeries Kinzu V2 Gaming Mouse' 6 | # Adaptive Decel — set nothing of this 7 | xinput set-prop "$MOUSE" "Device Accel Adaptive Deceleration" 1 8 | 9 | # Constant Decel — The Kinzu V2 Mouse need nothing here in the default settings. 10 | xinput set-prop "$MOUSE" "Device Accel Constant Deceleration" 1.9 11 | 12 | # Accel profile (6 = linear) — Pick a linear accel curve on which to place accel parameters. 13 | # I like the linear profile more than I like the polynomial one, hence this setting. 14 | xinput set-prop "$MOUSE" "Device Accel Profile" 6 15 | 16 | # Velocity Scaling factor — Lower values means less accel kick in. 17 | # A decent accel kick-in here which means flicks has a lot of acceleration. 18 | xinput set-prop "$MOUSE" "Device Accel Velocity Scaling" 0.35 19 | 20 | 21 | -------------------------------------------------------------------------------- /bin/rsam.rc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | TERM=dumb 4 | plumber 5 | 6 | fn cd { builtin cd $1 && awd $sysname } 7 | tabstop=4 8 | 9 | font='/mnt/font/Lucida Grande/12a/font' 10 | #font='/mnt/font/Noto Sans/11a/font' 11 | 12 | lfont='/mnt/font/Source Code Pro/12a/font' 13 | 14 | SHELL=rc 15 | exec sam $* 16 | 17 | -------------------------------------------------------------------------------- /bin/sam.rc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | TERM=dumb 4 | plumber 5 | 6 | fn cd { builtin cd $1 && awd $sysname } 7 | tabstop=4 8 | 9 | font='/mnt/font/Lucida Grande/15a/font' 10 | #font='/mnt/font/Noto Sans/13a/font' 11 | 12 | lfont='/mnt/font/Source Code Pro/14a/font' 13 | 14 | SHELL=rc 15 | exec sam $* 16 | 17 | -------------------------------------------------------------------------------- /bin/winclear: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rc 2 | 3 | echo -n , | 9p write acme/$winid/addr 4 | 9p write acme/$winid/data 0-9_/\-]*[a-zA-Z¡-0-9_/\-])", line ([0-9]+)?' 8 | arg isfile $1 9 | data set $file 10 | attr add addr=$2 11 | plumb to edit 12 | plumb client $editor 13 | 14 | type is text 15 | data matches 'File "([.a-zA-Z¡-0-9_/\-]*[a-zA-Z¡-0-9_/\-])", line ([0-9]+), characters ([0-9]+)-([0-9]+):' 16 | arg isfile $1 17 | data set $file 18 | attr add addr=$2-#0+#$3,$2-#0+#$4 19 | plumb to edit 20 | plumb client $editor 21 | 22 | # Erl Man Pages 23 | type is text 24 | data matches '([a-zA-Z¡-￿0-9_\-./]+)\(([1-8])erl\)' 25 | plumb start rc -c 'erl -man '$2' '$1' >[2=1] | nobs | plumb -i -d edit -a ''action=showdata filename=/man/'$1'('$2')''' 26 | 27 | # Github 28 | type is text 29 | data matches 'GH/([a-zA-z0-9]+)/([a-zA-Z0-9_\-]+)/([0-9a-f]+)' 30 | plumb to web 31 | plumb start web http://github.com/$1/$2/commit/$3 32 | 33 | type is text 34 | data matches 'GH/([a-zA-z0-9]+)/([a-zA-Z0-9_\-]+)#([0-9]+)' 35 | plumb to web 36 | plumb start web http://github.com/$1/$2/issues/$3 37 | 38 | type is text 39 | data matches 'GH/([a-zA-z0-9]+)/([a-zA-Z0-9_\-]+)' 40 | plumb to web 41 | plumb start web http://github.com/$1/$2 42 | 43 | include basic 44 | -------------------------------------------------------------------------------- /skel/x.app.src: -------------------------------------------------------------------------------- 1 | {application, x, 2 | [ 3 | {description, "The X application"}, 4 | {vsn, "0.1"}, 5 | {registered, []}, 6 | {applications, [ 7 | kernel, 8 | stdlib 9 | ]}, 10 | {modules, []}, 11 | {mod, { x_app, []}}, 12 | {env, []} 13 | ]}. 14 | -------------------------------------------------------------------------------- /skel/x_app.erl: -------------------------------------------------------------------------------- 1 | -module(x_app). 2 | 3 | -behaviour(application). 4 | 5 | %% Application callbacks 6 | -export([start/2, stop/1]). 7 | 8 | %% =================================================================== 9 | %% Application callbacks 10 | %% =================================================================== 11 | 12 | start(_StartType, _StartArgs) -> 13 | x_sup:start_link(). 14 | 15 | stop(_State) -> 16 | ok. 17 | -------------------------------------------------------------------------------- /skel/x_srv.erl: -------------------------------------------------------------------------------- 1 | -module(x_srv). 2 | 3 | -behaviour(gen_server). 4 | 5 | -export([ 6 | code_change/3, handle_call/3, handle_cast/2, handle_info/2, init/1, terminate/2 7 | ]). 8 | 9 | -export([ 10 | start_link/0 11 | ]). 12 | 13 | -record(state, { 14 | }). 15 | 16 | %% API 17 | 18 | start_link() -> 19 | gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). 20 | 21 | %% Callbacks 22 | 23 | init([]) -> 24 | {ok, #state{}}. 25 | 26 | handle_call(Msg, _From, State) -> 27 | ok = lager:error("Unknown call: ~p", [Msg]), 28 | {reply, {error, unknown}, State}. 29 | 30 | handle_cast(Msg, State) -> 31 | ok = lager:error("Unknown cast: ~p", [Msg]), 32 | {noreply, State}. 33 | 34 | handle_info(Msg, State) -> 35 | ok = lager:error("Unknown handle_info: ~p", [Msg]), 36 | {noreply, State}. 37 | 38 | terminate(_Reason, _State) -> 39 | ok. 40 | 41 | code_change(_OldVsn, State, _Extra) -> 42 | {ok, State}. 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /skel/x_sup.erl: -------------------------------------------------------------------------------- 1 | -module(x_sup). 2 | 3 | -behaviour(supervisor). 4 | 5 | %% API 6 | -export([start_link/0]). 7 | 8 | %% Supervisor callbacks 9 | -export([init/1]). 10 | 11 | %% Helper macro for declaring children of supervisor 12 | -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}). 13 | 14 | %% =================================================================== 15 | %% API functions 16 | %% =================================================================== 17 | 18 | start_link() -> 19 | supervisor:start_link({local, ?MODULE}, ?MODULE, []). 20 | 21 | %% =================================================================== 22 | %% Supervisor callbacks 23 | %% =================================================================== 24 | 25 | init([]) -> 26 | Strategy = {one_for_all, 10, 3600}, 27 | {ok, {Strategy, []}}. 28 | --------------------------------------------------------------------------------