Command reference
ed cd []
Sets the directory the later commands on that machine run in. It is not sent to
the machine as a command; ed intercepts it, asks the machine where that path
resolves to, and records the answer.
ed <machine> cd <directory>ed <machine> cd -ed <machine> cdArguments
| Name | Type / values | Default | What it does |
|---|---|---|---|
<directory> |
a path on the machine, absolute or relative to the current one, or - |
omitted | Where to move to. Omitted means the home directory; - means back to the directory you were in before the last cd. |
cd is only intercepted when it is the whole command and there are at most two
words. ed devbox cd and ed devbox cd Desktop are interceptions;
ed devbox cd a b and the quoted one-shot ed devbox 'cd /tmp && pwd' are ordinary
commands that run and change nothing:
$ ed devbox 'cd /tmp && pwd'/tmp$ ed devbox pwd/home/youed devbox pwd /home/youed devbox cd Desktoped devbox pwd /home/you/Desktoped devbox ls lists Desktoped devbox cd - back to where you were beforeed devbox cd back to the home directoryBehaviour notes
A successful cd prints nothing and exits 0. Under the covers ed runs
pwd; cd -- '<target>' && pwd on the machine, prefixed with a cd into the
directory you were already in, and keeps two lines: the first pwd becomes the
previous directory and the second becomes the current one. That is why -
works, and why it toggles rather than walking a stack.
The pair is stored in a file at
~/Library/Application Support/Edith/machines/cwd/<machine>/<session>, where
<machine> is the first ten characters of the machine's id with the dashes
removed and <session> is the name of the terminal your stdin is attached to,
/dev/ stripped and anything that is not a letter or a digit turned into a
dash. So /dev/ttys012 becomes ttys012, and two tabs on one machine never
move each other, the same way cd behaves in a local shell. When stdin is not a
terminal, which covers a pipe, a script and a cron job, the session is called
shared and every such invocation uses the same slot. The directory is created
mode 0700 and the file is written atomically.
A path that does not exist is reported with the machine's own message, exits 1, and leaves the stored directory alone:
$ ed devbox cd nosuchdirerror: cannot change to nosuchdir on Devboxhint: bash: line 1: cd: nosuchdir: No such file or directorycd - with nothing recorded for this terminal exits 1 with no previous directory for <machine> in this terminal, decided locally once the connection
is open and without asking the machine anything. The round trip a cd does
make is under the 60 second command timeout that ed puts on ordinary
commands, unlike the command path, which has none.
--tty reads the remembered directory but never sets it. The terminal branch
runs before the cd interception, so ed machines exec --tty devbox cd Desktop
changes directory inside that one pty session and nothing survives it.
The remembered directory reaches exactly two things: ed machines exec,
including the shorthand and the --tty form, and remote path completion.
Everything else keeps its own defaults, so ed machines files ls devbox still
lists the remote home directory after ed devbox cd Desktop, and the app's own
terminal and Finder windows are unaffected.
Where to go next
- Running commands on a machine, the rest of this group
- All
edcommands