Skip to content

Commit 17fb156

Browse files
authored
docs: add OSC-7 working-directory tracking documentation (#2211)
## Background & Motivation After installing Wave Terminal, new tabs and splits always started in my home folder instead of the current project directory, contrary to expectations from other terminals I've used. For context, I use `bash` for my shell. The existing documentation did not provide guidance about the required OSC 7 setup, so I had to dig into GitHub issues and source code to discover that Wave relies on a terminal escape sequence to track the shell’s working directory. This confusion represents a barrier for first-time users. ## Description This PR introduces a new documentation page—**Tracking Your Shell’s Working Directory**—which: 1. Explains **why** Wave uses the OSC 7 escape sequence to keep its internal `cmd:cwd` metadata in sync with your shell. 2. Provides copy-and-paste snippets to **enable** OSC 7 in **Bash**, **Zsh**, and **Fish**. 3. Details **verification steps** in the Wave UI to confirm correct CWD tracking. By making this enhancement, users can: - Open new tabs or split panes with their current working directory. - Avoid the `ERRCWD invalid cwd` errors in some shell configurations. - Spend less time troubleshooting and more time working. ## Changes - **Added** `docs/docs/track-cwd.mdx` (new page to enable OSC 7). - **Updated** `docs/docs/index.mdx` (linked the new page under **Other References**). ## Related Issues - <#1130> — New tabs should inherit the CWD. - <#2057> — Split panes always start in home directory. ## Testing & Review 1. **Local build** ```bash cd waveterm yarn task docsite ``` - Confirm the new “Tracking Your Shell’s Working Directory” page appears in the sidebar. - Verify the instructions and code samples render correctly. 2. **Content review** - Are the shell snippets accurate? - Is the enable → verify flow clear and complete? --- _I have followed the [contributing guidelines](https://github.com/wavetermdev/waveterm/blob/main/CONTRIBUTING.md) and used a conventional commit message._
1 parent 1cdd746 commit 17fb156

1 file changed

Lines changed: 83 additions & 1 deletion

File tree

docs/docs/faq.mdx

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,95 @@ Just remember in JSON, backslashes need to be escaped. So add this to your [sett
3535

3636
`wsh` is an internal CLI for extending control over Wave to the command line, you can learn more about it [here](./wsh). To prevent misuse by other applications, `wsh` requires an access token provided by Wave to work and will not function outside of the app.
3737

38+
### How do I make new blocks or splits inherit my shell’s current directory?
39+
40+
Wave uses a special escape sequence (OSC 7) to track the shell’s working directory and maintain the working directory of new terminal blocks and splits. Wave listens for these sequences to update its `cmd:cwd` metadata. That metadata is copied to new blocks when you:
41+
42+
- Open a new terminal block (Alt N / Cmd N)
43+
- Split a pane (Cmd D / Cmd Shift D)
44+
45+
Not all shells emit this escape sequence, so new blocks or splits may start in your home directory instead. To ensure your shell emits the OSC 7 escape sequence, add the following to your shell startup/config file and restart Wave (or source your config).
46+
47+
#### Bash
48+
49+
Add to `~/.bashrc` or `~/.bash_profile`:
50+
51+
```bash
52+
# Emit OSC 7 on each prompt to tell terminal about new working directory
53+
__update_cwd() {
54+
# Only run in interactive shells
55+
[[ $- == *i* ]] || return
56+
# Only run if attached to a terminal
57+
[ -t 1 ] || return
58+
# Redirect to tty so output doesn't show in shell
59+
printf "\033]7;file://%s%s\007" "$HOSTNAME" "${PWD// /%20}" > /dev/tty
60+
}
61+
if [[ -n "$PROMPT_COMMAND" ]]; then
62+
export PROMPT_COMMAND="__update_cwd; $PROMPT_COMMAND"
63+
else
64+
export PROMPT_COMMAND="__update_cwd"
65+
fi
66+
```
67+
68+
#### Zsh
69+
70+
Add to `~/.zshrc`:
71+
72+
```zsh
73+
# Emit OSC 7 escape on directory change and prompt
74+
function _wave_emit_cwd() {
75+
printf "\033]7;file://%s%s\007" "$HOSTNAME" "${PWD// /%20}" > /dev/tty
76+
}
77+
autoload -U add-zsh-hook
78+
add-zsh-hook chpwd _wave_emit_cwd
79+
add-zsh-hook precmd _wave_emit_cwd
80+
```
81+
82+
#### Fish
83+
84+
> Fish shell (v4.0.0 and later) emits OSC 7 by default—no config required.
85+
86+
For older Fish versions, add to `~/.config/fish/config.fish`:
87+
88+
```fish
89+
# Emit OSC 7 on each PWD change
90+
function _wave_emit_cwd --on-variable PWD
91+
printf "\033]7;file://%s%s\007" (hostname) (string replace ' ' '%20' $PWD) > /dev/tty
92+
end
93+
```
94+
95+
After configuring, open a new block or split (Alt T / Cmd T, Alt N / Cmd N, Cmd D / Cmd Shift D) and verify blocks start in your current directory.
96+
97+
#### Verifying Current Directory Preservation
98+
99+
1. Open a Wave terminal block.
100+
2. `cd` into a project folder, e.g. `cd ~/projects/foo`.
101+
3. Right-click on the block's title bar and select "Copy BlockId" to retrieve the block’s ID.
102+
4. Use the copied BlockId to retrieve the block’s metadata:
103+
104+
```bash
105+
# Example: replace BLOCK_ID with your actual block reference
106+
wsh getmeta --block BLOCK_ID
107+
```
108+
109+
5. Confirm the output JSON contains a `cmd:cwd` field, for example:
110+
111+
```json
112+
{
113+
"cmd:cwd": "/Users/you/projects/foo",
114+
...
115+
}
116+
```
117+
118+
6. Open a new block or split the pane—both should start in `/Users/you/projects/foo`.
119+
38120
## Why does Wave warn me about ARM64 translation when it launches?
39121

40122
macOS and Windows both have compatibility layers that allow x64 applications to run on ARM computers. This helps more apps run on these systems while developers work to add native ARM support to their applications. However, it comes with significant performance tradeoffs.
41123

42124
To get the best experience using Wave, it is recommended that you uninstall Wave and reinstall the version that is natively compiled for your computer. You can find the right version by consulting our [Installation Instructions](./gettingstarted#installation).
43125

44-
You can disable this warning by setting `app:dismissarchitecturewarning=true` in [your configurations](./config.mdx).
126+
You can disable this warning by setting `app:dismissarchitecturewarning=true` in [your configurations](./config).
45127

46128
## How do I join the beta builds of Wave?
47129

0 commit comments

Comments
 (0)