Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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