top | item 42403262

(no title)

model-15-DAV | 1 year ago

As an addendum to Rule 7, `cd -` takes you to the last opened directory. Or is `cd` considered part of the terminal emulator's job, as a built-in?

discuss

order

saghm|1 year ago

I don't think it's part of the terminal emulator (e.g. xterm, gnome-terminal) but the shell (bash, zsh, etc.). You're correct that it's not something that's implemented as an external program though; the "current directory" is state for a currently running terminal session, so changing that state is done via the shell interface (either directly by built-in commands like cd or indirectly via external commands that use those transitively).

machinestops|1 year ago

Note: Child processes can't change the working directory of the parent. An external command (that is, not a shell builtin, shell function, or externally loaded module) cannot change the working directory, because they're launched as child processes.

model-15-DAV|1 year ago

True, I meant the shell, as `cd` is a shell builtin. However, `git-checkout` does implement this behavior. `git checkout -` will checkout the previously checked out branch.