rwd 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. .SH SOURCE
  132. .B /rc/bin/rwd
  133. .br
  134. .B /sys/src/cmd/aux/conswdir.c
  135. .SH SEE ALSO
  136. .IR plumber (4),
  137. .IR plumb (6),
  138. .IR srv (4)
  139. .SH BUGS
  140. This mechanism is clunky, but Unix and SSH
  141. make it hard to build a better one.
  142. .PP
  143. This doesn't handle rooted path names.
  144. .PP
  145. The escape sequence was chosen because
  146. it changes the title on xterm windows.