aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-06-15 16:44:23 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-06-16 17:02:10 +0000
commitbdb79e8b9fb36f627bb204ce2060dd5a877f3712 (patch)
tree1c3f46e4cd1724639a7db1f92bf0c81bc2f885c0 /README.md
parentime: track IME focus independently from keyboard focus (diff)
osc: add support for OSC 133;A (prompt markers)
This patch adds support for the OSC-133;A sequence, introduced by FinalTerm and implemented by iTerm2, Kitty and more. See https://iterm2.com/documentation-one-page.html#documentation-escape-codes.html. The shell emits the OSC just before printing the prompt. This lets the terminal know where, in the scrollback, there are prompts. We implement this using a simple boolean in the row struct ("this row has a prompt"). The prompt marker must be reflowed along with the text on window resizes. In an ideal world, erasing, or overwriting the cell where the OSC was emitted, would remove the prompt mark. Since we don't store this information in the cell struct, we can't do that. The best we can do is reset it in erase_line(). This works well enough in the "normal" screen, when used with a "normal" shell. It doesn't really work in fullscreen apps, on the alt screen. But that doesn't matter since we don't support jumping between prompts on the alt screen anyway. To be able to jump between prompts, two new key bindings have been added: prompt-prev and prompt-next, bound to ctrl+shift+z and ctrl+shift+x respectively. prompt-prev will jump to the previous, not currently visible, prompt, by moving the viewport, ensuring the prompt is at the top of the screen. prompt-next jumps to the next prompt, visible or not. Again, by moving the viewport to ensure the prompt is at the top of the screen. If we're at the bottom of the scrollback, the viewport is instead moved as far down as possible. Closes #30
Diffstat (limited to 'README.md')
-rw-r--r--README.md54
1 files changed, 52 insertions, 2 deletions
diff --git a/README.md b/README.md
index 227c528c..348f2e18 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,9 @@ The fast, lightweight and minimalistic Wayland terminal emulator.
1. [Mouse](#mouse)
1. [Server (daemon) mode](#server-daemon-mode)
1. [URLs](#urls)
+1. [Shell integration](#shell-integration)
+ 1. [Current working directory](#current-working-directory)
+ 1. [Jumping between prompts](#jumping-between-prompts)
1. [Alt/meta](#alt-meta)
1. [Backspace](#backspace)
1. [Keypad](#keypad)
@@ -157,13 +160,21 @@ These are the default shortcuts. See `man foot.ini` and the example
<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>n</kbd>
: Spawn a new terminal. If the shell has been [configured to emit the
OSC 7 escape
- sequence](https://codeberg.org/dnkl/foot/wiki#user-content-how-to-configure-my-shell-to-emit-the-osc-7-escape-sequence),
+ sequence](https://codeberg.org/dnkl/foot/wiki#user-content-spawning-new-terminal-instances-in-the-current-working-directory),
the new terminal will start in the current working directory.
<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>u</kbd>
: Enter URL mode, where all currently visible URLs are tagged with a
jump label with a key sequence that will open the URL.
+<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>z</kbd>
+: Jump to the previous, currently not visible, prompt. Requires [shell
+ integration](https://codeberg.org/dnkl/foot/wiki#user-content-jumping-between-prompts).
+
+<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>x</kbd>
+: Jump to the next prompt. Requires [shell
+ integration](https://codeberg.org/dnkl/foot/wiki#user-content-jumping-between-prompts).
+
#### Scrollback search
@@ -296,6 +307,44 @@ Jump label colors, the URL underline color, and the letters used in
the jump label key sequences can be configured.
+## Shell integration
+
+### Current working directory
+
+New foot terminal instances (bound to
+<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>n</kbd> by default) will open in
+the current working directory, **if** the shell in the “parent”
+terminal reports directory changes.
+
+This is done with the OSC-7 escape sequence. Most shells can be
+scripted to do this, if they do not support it natively. See the
+[wiki](https://codeberg.org/dnkl/foot/wiki#user-content-spawning-new-terminal-instances-in-the-current-working-directory)
+for details.
+
+
+### Jumping between prompts
+
+Foot can move the current viewport to focus prompts of already
+executed commands (bound to
+<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>z</kbd>/<kbd>x</kbd> by
+default).
+
+For this to work, the shell needs to emit an OSC-133;A
+(`\E]133;A\E\\`) sequence before each prompt.
+
+In zsh, one way to do this is to add a `precmd` hook:
+
+```zsh
+precmd() {
+ print -Pn "\e]133;A\e\\"
+}
+```
+
+See the
+[wiki](https://codeberg.org/dnkl/foot/wiki#user-content-jumping-between-prompts)
+for details, and examples for other shells.
+
+
## Alt/meta
By default, foot prefixes _Meta characters_ with ESC. This corresponds
@@ -392,7 +441,7 @@ with the terminal emulator itself. Foot implements the following OSCs:
supported)
* `OSC 2` - change window title
* `OSC 4` - change color palette
-* `OSC 7` - report CWD
+* `OSC 7` - report CWD (see [shell integration](#shell-integration))
* `OSC 8` - hyperlink
* `OSC 9` - desktop notification
* `OSC 10` - change (default) foreground color
@@ -408,6 +457,7 @@ with the terminal emulator itself. Foot implements the following OSCs:
* `OSC 112` - reset cursor color
* `OSC 117` - reset highlight background color
* `OSC 119` - reset highlight foreground color
+* `OSC 133` - [shell integration](#shell-integration)
* `OSC 555` - flash screen (**foot specific**)
* `OSC 777` - desktop notification (only the `;notify` sub-command of
OSC 777 is supported.)