diff --git a/README.md b/README.md index 12fdbaa..73c4dc7 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,174 @@ -# My wezterm configuration +# My wezterm config - -- [My wezterm configuration](#my-wezterm-configuration) - - [Features](#features) - - [Mode indicator](#mode-indicator) - - [Vim-style keymaps](#vim-style-keymaps) - - [Flexible status-bar](#flexible-status-bar) - - -![configuration showcase](./.github/assets/showcase.png) +![configuration showcase](./.github/assets/config-showcase.png) ## Features -### Mode indicator +### Flexible status-bar -Four mode are currenty supported: +![flexible status bar showcase](./.github/assets/flexible-status-bar-showcase.webm) -![showcase search mode](./.github/assets/mode-search-showcase.png) +This configuration provides a flexible and responsive status bar for WezTerm, +ensuring important information is always visible and adapts gracefully to changes +in terminal size. -![showcase copy mode](./.github/assets/mode-copy-showcase.png) +The configuration attempts to display the most detailed version of each +status-bar element. If space is insufficient, it falls back to shorter versions +or omits the element entirely. It shows the full path, a shortened path, or an +abbreviated path for the current working directory (CWD). For the hostname, it +displays the full hostname or its first letter if space is limited. Date and time +are shown in various formats: full date and time, date in dd/mm format, or +only the time. The battery status is represented by the full battery status with +icon and percentage, percentage only, or icon only. -![showcase window mode](./.github/assets/mode-window-showcase.png) +Compare to stock Wezterm: -![showcase font mode](./.github/assets/mode-font-showcase.png) +![stock wezterm status-bar](./.github/assets/stock-wezterm-status-bar.png) -Search, copy and window mode have vim-like mappings. +### Mode indicator -Each mode also changes the status-bar colors! ([can be easily disabled](https://github.com/sravioli/wezterm/blob/main/events/update-status.lua#L28)) +![showcase window mode](./.github/assets/window-mode-showcase.png) + +![showcase search mode](./.github/assets/search-mode-showcase.png) + +![showcase copy mode](./.github/assets/copy-mode-showcase.png) + +![showcase font mode](./.github/assets/font-mode-showcase.png) + +The mode indicator highlights the current operational mode of the terminal, such +as copy mode, search mode, window mode or font mode. Each mode is represented by +a distinct label and background color, providing a clear visual cue. The mode +indicator is positioned on the left side of the status-bar. + +The mode indicator supports customization through the [`modes` +table](./events/update-status.lua), which defines the text label and background +color for each mode. The configuration listens for changes in the active key +table and updates the mode indicator accordingly. This feature provides +immediate feedback on the terminal's operational state. + +Search, window and copy mode feature vim-like keymaps. + + +
+ copy-mode + + | Key | Action | + | ------------- | ---------------------------------------- | + | ``/`` | Exit copy mode | + | `` | Jump word forward | + | `` | Jump word backward | + | `` | Jump to start of next line | + | `` | Set selection mode to cell | + | `0` | Jump to start of line | + | `$` | Jump to end of line content | + | `^` | Jump to start of line content | + | `,` | Jump again backward | + | `;` | Jump again | + | `F` | Jump backward (prev char off) | + | `f` | Jump forward (prev char off) | + | `T` | Jump backward (prev char on) | + | `t` | Jump forward (prev char on) | + | `G` | Jump to scrollback bottom | + | `g` | Jump to scrollback top | + | `h` | Move left | + | `j` | Move down | + | `k` | Move up | + | `l` | Move right | + | `H` | Jump to viewport top | + | `L` | Jump to viewport bottom | + | `M` | Jump to viewport middle | + | `V` | Set selection mode to line | + | `v` | Set selection mode to cell | + | `` | Set selection mode to block | + | `O` | Jump to selection other end (horizontal) | + | `o` | Jump to selection other end | + | `b` | Jump backward word | + | `e` | Jump forward word end | + | `w` | Jump forward word | + | `` | Move by page down | + | `` | Move by page up | + | `y` | Copy selection and exit | + +
+ +
+ search-mode + + | Key | Action | + | ------------- | ------------------------ | + | ``/`` | Exit search mode | + | `` | Jump to prior match | + | `` | Jump to next match | + | `` | Jump to prior match | + | `` | Cycle match type | + | `` | Clear search pattern | + | `` | Jump to prior match page | + | `` | Jump to next match page | + | `` | Jump to prior match | + | `` | Jump to next match | + +
+ +
+ font-mode + + | Key | Action | + | ------------- | ------------------ | + | ``/`` | Exit font mode | + | `+` | Increase font size | + | `-` | Decrease font size | + | `0` | Reset font size | + +
+ +
+ window-mode + + | Key | Action | + | --------------| ----------------------------- | + | ``/`` | Exit window mode | + | `p` | Pick pane | + | `x` | Swap with active pane | + | `q` | Close current pane | + | `o` | Toggle pane zoom state | + | `v` | Split horizontal | + | `s` | Split vertical | + | `` | Activate pane to the left | + | `` | Activate pane below | + | `` | Activate pane above | + | ``| Activate pane to the right | + | `h` | Activate pane to the left | + | `j` | Activate pane below | + | `k` | Activate pane above | + | `l` | Activate pane to the right | + | `<` | Adjust pane size to the left | + | `>` | Adjust pane size to the right | + | `+` | Adjust pane size upwards | + | `-` | Adjust pane size downwards | + +
+ ### Vim-style keymaps -Mappings are defined using vim-like syntax, with the added `W` modifier that -maps to the `SUPER`/`WINDOWS` key. +The config defines custom key bindings, inspired by Vim's keymap system. + +The `` (`LEADER` for wezterm) key is `` (Alt + Backspace). + +The key bindings are defined using Vim syntax, allowing users to leverage their +familiarity with Vim's intuitive keymap system. Key combinations try to follow +the same conventions as Vim, with the added modifier of `W` that maps to the +`SUPER`/`WINDOWS` key. + +Switching mode is made possibile using designated leader key combinations: +`w` for window mode, `f` for font mode, `c` for copy mode +and `s` for search mode. + +Additional adjustments and bindings can be effortlessly incorporated to cater to +individual preferences and requirements. Adding or modifing existing keymaps is +very easy: add (or remove) the desired keymap to the table in +[./mappings/default.lua](./mappings/default.lua). The keymap will be +automatically converted to Wezterm's syntax. Usage example as follows: @@ -47,63 +184,71 @@ return Config the previous mapping will be translated to: ~~~lua -{ - key = "Enter", - mods = "ALT", - action = act.ToggleFullScreen -} +{ key = "Enter", mods = "ALT", action = act.ToggleFullScreen } ~~~ -I find it easier to just use a loop: - -~~~lua -local fun = require("utils.fun") - -local keys = { - ["\\"] = act.SendKey { key = "\\" }, ---send key on - [""] = act.ActivateTabRelative(1), - [""] = act.ActivateTabRelative(-1), - [""] = act.ToggleFullScreen, - [""] = act.CopyTo "Clipboard", - [""] = act.PasteFrom "Clipboard", - [""] = act.Search "CurrentSelectionOrEmptyString", - [""] = act.ClearScrollback "ScrollbackOnly", - -- ... -} - -Config.keys = {} -for lhs, rhs in pairs(keys) do - fun.map(lhs, rhs, Config.keys) -end -~~~ + +
+ default keymaps + + | Key Combination | Action | + |-----------------|------------------------------------------| + | `` | Next Tab | + | `` | Previous Tab | + | `` | Toggle Fullscreen | + | `` | Copy to Clipboard | + | `` | Paste from Clipboard | + | `` | Search Current Selection or Empty String | + | `` | Clear Scrollback Buffer | + | `` | Show Debug Overlay | + | `` | Spawn New Window | + | `` | Activate Command Palette | + | `` | Reload Configuration | + | `` | Spawn Tab in Current Pane Domain | + | `` | Character Select (Copy to Clipboard) | + | `` | Close Current Tab (with confirmation) | + | `` | Toggle Pane Zoom State | + | `` | Scroll Up by Page | + | `` | Scroll Down by Page | + | `` | Paste from Primary Selection | + | `` | Copy to Primary Selection | + | `` | Quick Select | + | `` | Split Horizontal (Current Pane Domain) | + | `` | Split Vertical (Current Pane Domain) | + | `` | Activate Pane Direction (Left) | + | `` | Activate Pane Direction (Down) | + | `` | Activate Pane Direction (Up) | + | `` | Activate Pane Direction (Right) | + | `w` | Activate Window Mode | + | `f` | Activate Font Mode | + | `` | Activate Lock Mode | + | `c` | Activate Copy Mode | + | `s` | Search Current Selection or Empty String | + | `` | Activate Tab 1 | + | `` | Activate Tab 2 | + | `` | Activate Tab 3 | + | `` | Activate Tab 4 | + | `` | Activate Tab 5 | + | `` | Activate Tab 6 | + | `` | Activate Tab 7 | + | `` | Activate Tab 8 | + | `` | Activate Tab 9 | + | `` | Activate Tab 10 | + +
+ -Don't forget to set a `LEADER`! - -For the full mappings list take a look at -[./mappings/default.lua](./mappings/default.lua) and -[./mappings/modes.lua](./mappings/modes.lua). - -### Flexible status-bar - -https://github.com/sravioli/wezterm/assets/76562615/59785192-34b3-4e57-9804-cf2e64225887 - -The status bar will give priority to the tab bar. During the status bar evaluation -the available width is calculated and elements are not rendered to gracefully -truncate the status-bar. - -The width is calculated using and some -other things, for more info take a look at [./events/update-status.lua](./events/update-status.lua) +### Multiple fonts -Currenty trying to figure out how to add fallback for each cell, i.e. if there -isn't enough space to render the full cell, fallback to a shorter one, if the -space is still not enough, hide the cell, for example: +The base font is [Fira Code +NerdFont](https://www.nerdfonts.com). +[Monaspace Radon](https://github.com/githubnext/monaspace/releases/latest) is +used for italics and [Monaspace +Krypton](https://github.com/githubnext/monaspace/releases/latest) is used for +bold-italics. -~~~text - [try] too long? [try] too long? -2023-12-14 11:05 ----------> 11:06 ----------> "" -~~~ - -### Multiple fonts +### Thanks -The base font is Fira Code NF. Monaspace Radon is used for italics and Monaspace -Krypton is used for bold-italics. +Special thanks to [@Wez](https://www.github.com/wez) (of course) and to +[@apredezdc](https://github.com/aperezdc/) for +[lua-wcwidth](https://github.com/aperezdc/lua-wcwidth)