From ae357ccc3175ec95d0b3283236f988aedf86d5a6 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 15 Feb 2020 13:59:21 -0800 Subject: [PATCH] docs: add info about using OSC 7 refs: https://github.com/wez/wezterm/issues/146 --- docs/SUMMARY.md | 1 + docs/changelog.markdown | 2 ++ docs/shell-integration.markdown | 45 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 docs/shell-integration.markdown diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 6b1cd9c8b..486897044 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -9,6 +9,7 @@ - [Key Binding](config/keys.markdown) - [Colors & Appearance](config/appearance.markdown) - [Hyperlinks](hyperlinks.markdown) +- [Shell Integration](shell-integration.markdown) - [iTerm Image Protocol](imgcat.markdown) - [SSH](ssh.markdown) - [Serial Ports & Arduino](serial.markdown) diff --git a/docs/changelog.markdown b/docs/changelog.markdown index 72052dd21..599829870 100644 --- a/docs/changelog.markdown +++ b/docs/changelog.markdown @@ -19,6 +19,8 @@ brief notes about them may accumulate here. * Added `QuitApplication` key action which causes the gui loop to terminate and the application to exit. This is not bound by default, but you may choose to assign it to something like `CMD-Q`. +* Added `set_environment_variables` configuration section to allow defining + some environment variables to be passed to your shell. ### 20200202-181957-765184e5 diff --git a/docs/shell-integration.markdown b/docs/shell-integration.markdown new file mode 100644 index 000000000..4ca143eb4 --- /dev/null +++ b/docs/shell-integration.markdown @@ -0,0 +1,45 @@ +## Shell Integration + +wezterm supports integrating with the shell through the following means: + +### OSC 7 Escape sequence to set the working directory + +`OSC` is escape sequence jargon for *Operating System Command*; `OSC 7` means +Operating System Command number 7. This is an escape sequence that originated +in the macOS Terminal application that is used to advise the terminal of the +current working directory. + +An application (usually your shell) can be configured to emit this escape +sequence when the current directory changes, or just to emit it each time +it prints the prompt. + +The current working directory can be specified as a URL like this: + +```bash +printf "\033]7;file://HOSTNAME/CURRENT/DIR\033\\" +``` + +**When the current working directory has been set via OSC 7, spawning +a new tab will use the current working directory of the current tab, +so that you don't have to manually change the directory**. + +If you are on a modern Fedora installation, the defaults for bash and +zsh source a `vte.sh` script that configures the shell to emit this +sequence. On other systems you will likely need to configure this +for yourself. + +### OSC 7 on Windows with cmd.exe + +`cmd.exe` doesn't allow a lot of flexibility in configuring the prompt, +but fortunately it does allow for emitting escape sequences. You +can use the `set_environment_variables` configuration to pre-configure +the prompt environment in your `wezterm.toml`; this example configures +the use of OSC 7 as well as including the time and current directory in +the visible prompt with green and purple colors, and makes the prompt +span multiple lines: + +```toml +[set_environment_variables] +prompt = "$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m " +``` +