summaryrefslogtreecommitdiff
path: root/sys/man/1/rwd
blob: 14e1a57cec9af5ae77133247d1b6133231845e6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
.TH RWD 1
.SH NAME
rwd, conswdir \- maintain remote working directory
.SH SYNOPSIS
.B rwd
.I path
.PP
.B conswdir
[
.I prog
]
.SH DESCRIPTION
.I Rwd
and
.I conswdir
conspire to keep 
.IR rio (4)
and
.IR acme (4)
informed about the current directory on
remote systems during login sessions.
.I Rio
and
.I acme
include this information in plumb messages sent to
.IR plumber (4).
If the remote system's name space is mounted in the
plumber's name space,
the end result is that file paths printed during the session
are plumbable.
.PP
.I Rwd
informs
.IR rio
and
.IR acme
of directory changes.
The name of the remote machine is taken from
the environment variable
.BR $remotesys .
.I Rwd
writes the full path to
.BR /dev/wdir ;
writes the last element of the path,
suffixed by
.BI @ remotesys \fR,
to
.BR /dev/label ;
and when run inside a 
.I win
(see
.IR acme (1))
window, changes the window title to
.IB path /- remotesys
using
.BR /dev/acme/ctl .
.PP
.I Conswdir
copies standard input to standard output, looking for in-band messages
about directory changes.
The messages are of the form:
.IP
.EX
\e033];\fIpath\fP\e007
.EE
.LP
where
.B \e033
and
.B \e007
are ASCII escape and bell characters.
Such messages are removed from the stream and not printed to standard output;
for each such message
.I conswdir
runs
.I prog
(default
.BR /bin/rwd )
with
.I path
as its only argument.
.SH EXAMPLES
Add this plumbing rule (see
.IR plumb (6))
in order to run commands in the plumber's name space:
.IP
.EX
# have plumber run command
kind is text
data matches 'Local (.*)'
plumb to none
plumb start rc -c $1
.EE
.PP
Mount a Unix system in your name space and the plumber's:
.IP
.EX
% 9fs unix
% plumb 'Local 9fs unix'
.EE
.LP
(If you're using acme, execute
.B "Local 9fs unix
with the middle button to mount the Unix system in acme's name space.)
.PP
Connect to the Unix system, processing in-band directory change messages:
.IP
.EX
% ssh unix | aux/conswdir
.EE
.PP
Add this shell function to your
.B .profile
on the Unix system
to generate directory change messages every time a
.B cd
command is executed:
.IP
.EX
H=`hostname | sed 's/\e..*//'`
_cd () {
	\ecd $* &&
	case $- in
	*i*)
		_dir=`pwd`
		echo /n/$H$_dir | awk '{printf("\e033];%s\e007", $1);}'
	esac
}
alias cd=_cd
.EE
.PP
The examples described so far only help for relative
path names.  Add this plumbing rule to handle rooted names
like
.BR /usr/include/stdio.h :
.IP
.EX
# remote rooted path names
type is text
wdir matches '/n/unix(/.*)?'
data matches '/([.a-zA-Z¡-￿0-9_/\e-]*[a-zA-Z¡-￿0-9_/\e-])('$addr')?'
arg isfile /n/unix/$1
data set $file
attr add addr=$3
plumb to edit
plumb client window $editor
.EE
.SH SOURCE
.B /rc/bin/rwd
.br
.B /sys/src/cmd/aux/conswdir.c
.SH SEE ALSO
.IR plumber (4),
.IR plumb (6),
.IR srv (4)
.SH BUGS
This mechanism is clunky, but Unix and SSH
make it hard to build a better one.
.PP
The escape sequence was chosen because
it changes the title on xterm windows.