-
-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to kdl #1759
Switch to kdl #1759
Conversation
Hey @har7an, thanks for the great and detailed comments! The quotation marks issue is a bit trickier to fix since this is a KDL de-serialization error which we catch and reword. I attempted to remedy the situation a little by changing it to this:
It might not be ideal, but I think along with a link to the documentation it's not overly bad. Otherwise - any more comments about the config/layout/cli experience? I think I'm mainly curious about the layout experience because that would be the most extreme change. |
Agreed, the link to the docs should help. I'm just not very happy with the formatting, because it's a lot of text squeezed into a very tight space imo. What would you say about something like this:
It's not too bad, really, since most users will probably look for the underlined text, or the numbers that are printed to the left of it (which, curiously, is correct in any case).
I'll try and poke around some more until this evening, I have great plans for a custom shell script. :) |
I notice Also some actions seem to get lost in oblivion when spamming actions too quickly. As an example, I wanted to write myself a little shell script that creates a custom layout with a split pane like so: 14 devtab)
13 if [[ $# -eq 2 ]]; then
12 if [[ -d "$2" ]]; then
11 pushd "$2"
10 fi
9 fi
8 $ZELLIJ action new-tab --name "devel"
7 sleep 0.1
6 $ZELLIJ action rename-pane shell
5 sleep 0.1
4 $ZELLIJ action new-pane --direction right --command "$EDITOR ."
3 sleep 0.1
2 $ZELLIJ action rename-pane editor
1 sleep 0.1
60 $ZELLIJ action move-pane left
1 ;; But the results are rather mixed. Note that I added the With the sleep statements it works, however. But that's not exactly ideal I think. Also |
Fair point, I think I'll add this after merging.
I forgot to mention this. This is an existing bug that I think happened because of a miscommunication between maintainers a while ago. Fixing it is out of scope here, IMO
This works for me... it should only work if paired with "command" though. Is that what you mean maybe?
This is true - I think I even mention in the docs somewhere that the actions will not necessarily run sequentially because with some actions we don't yet know when they end. Might be worth making this more explicit in the docs. However for this case - why not create a layout instead? That's what they are there for and I think it will be much easier. Is there a feature there you're missing?
That's definitely not on purpose! I think I'll also fix this after merging. |
To sum up what @har7an and I talked about offline:
Points 2-5 should allow more dynamic layouts which replicate the same flow for different folders without us having to commit to some sort of templating language for now (even though we are not ruling out the idea of a templating language for more dynamic content in the future). |
Before the release we should update the docs, since error messages point to it: |
There was a minor typo in the first post: pane_tempalte, I corrected it since this is supposed to be the documentation later. There are still 3 occurrences of this typo in the code if you care about them. |
Hello, |
Introduction
This PR introduces two main features:
Following is the initial documentation for all of these features (once this is merged, it will replace the relevant documentation on our website).
kdl.vim
To help us vim people edit KDL, I created: kdl.vim. I'm mentioning this here because I think it will also help trying out this change.
Conversion from old YAML files
As a matter of convenience, when Zellij is run with an old configuration / layout / theme file (either explicitly with a cli flag or if it found the file in the default locations) it will prompt the user and convert that file to the new format.
This can also be done manually:
Layouts
Layout documentation
This configuration change revamps and greatly simplifies the way we write layouts for Zellij.The layout structure is nested under a global
layout
node. Within it arepane
,tab
,pane_template
andtab_template
nodes that describe the layout.A basic example layout can look like this:
Which would create the following layout:
Panes
pane
nodes are the basic building blocks of a layout.They could represent standalone panes:
They could also represent logical containers:
Note: if panes represent logical containers, all their arguments should be specified on their title line.
split_direction
split_direction
is a pane argument that indicates whether its children will be laid out vertically or horizontally.Possible values:
"vertical"
|"horizontal"
Default value if omitted:
"horizontal"
eg.
Note: The
layout
node itself has a set value of "horizontal". It can be changed by adding a logical pane container:size
size
is a pane argument that represents the fixed or percentage space taken up by this pane inside its logical container.Possible values: bare integers representing fixed values (eg. 1) | quoted percentages (eg. "50%")
Note: specifying fixed values that are not
unselectable
plugins is currently unstable. Please see: #1758eg.
borderless
borderless
is a pane argument indicating whether a pane should have a frame or not.Possible values: true | false
Default value if omitted: false
eg.
focus
focus
is a pane argument indicating whether a pane should have focus on startup.Possible values: true | false
Default value if omitted: false
Note: specifying multiple panes with focus will result in the first one of them being focused.
eg.
name
name
is a string pane argument to change the default pane title.Possible values: "a quoted string"
eg.
cwd
A pane can have a
cwd
argument, pointing to its Current Working Directory.Possible values: "/path/to/some/folder", "relative/path/to/some/folder"
eg.
command
command
is a string (path) to an executable that should be run in this pane instead of the default shell.Possible values: "/path/to/some/executable" | "executable" (the latter should be accessible through PATH)
eg.
args
A pane with a
command
can also have anargs
argument. This argument can include one or more strings that will be passed to the command as its arguments.Possible values: "a" "series" "of" "quoted" "strings"
Note:
args
must be inside thepane
's child-braces and cannot be specified on the same line as the pane.eg.
edit
edit
is a string (path) to a file that will be opened using the editor specified in theEDITOR
orVISUAL
environment variables. This can alternatively also be specified using thescrollback_editor
config variable.Possible values: "/path/to/some/file" | "./relative/path/from/cwd"
eg.
plugin
plugin
is a pane argument the points to a Zellij plugin to load. Currently is is only possible to specify inside the child-braces of a pane followed by a URLlocation
in quoted string.Possible values:
zellij:internal-plugin
|file:/path/to/my/plugin.wasm
eg.
Tabs
tab
nodes can optionally be used to start a layout with several tabs.Note: all tab arguments should be specified on its title line. The child-braces are reserved for its child panes.
eg.
split_direction
Tabs can have a
split_direction
just likepane
s. This argument indicates whether the tab's children will be laid out vertically or horizontally.Possible values:
"vertical"
|"horizontal"
Default value if omitted:
"horizontal"
eg.
focus
Tabs can have a
focus
just likepane
s. This argument indicates whether a tab should have focus on startup.Possible values: true | false
Default value if omitted: false
Note: only one tab can be focused.
eg.
name
Tabs can have a
name
just likepane
s. This argument is a string to change the default tab title.Possible values: "a quoted string"
eg.
cwd
Tabs can have a
cwd
just likepane
s - pointing to their Current Working Directory.All panes in this tab will have this
cwd
prefixed to their owncwd
(if they have one) or start in thiscwd
if they don't.Possible values: "/path/to/some/folder", "relative/path/to/some/folder"
eg.
Templates
Templates can be used avoid repetition when creating layouts.
Each template has a name that should be used directly as a node name instead of "pane" or "tab".
Pane Templates
Pane templates can be used to shorten pane attributes:
Pane templates with the
command
attribute can take theargs
andcwd
of their consumers:Note: the above only works for direct consumers and not other templates.
Pane templates can be used as logical containers. In this case a special
children
node must be specified to indicate where the child panes should be inserted.Note: the
children
node can be nested insidepane
s but not inside otherpane_template
s.Pane templates can include other pane templates.
The
children
node should be thought of as a placeholder for the pane using this template.This:
Will be translated into this:
Tab Templates
Tab templates, similar to pane templates, help avoiding repetition when defining tabs. Like
pane_templates
they can include achildren
block to indicate where their child panes should be inserted.Note: for the sake of clarity, arguments passed to
tab_template
s can only be specified on their title line.Default Tab Template
There is a special
default_tab_template
node that can be used just like a regulartab_template
node, but that would apply to alltab
s in the template as well as all new tabs opened in the session.Note: the
default_tab_template
will not apply to tabs using othertab_template
s.Another note: if no
tab
s are specified, the whole layout is treated as adefault_tab_template
.Global
cwd
The
cwd
property can also be specified globally in thelayout
node itself. Doing this would make all panes in this layout start in this cwd unless they have an absolute path. If they have a relative path, it will be appended to the globalcwd
. This should allow greater flexibility when creating custom layouts.Eg.
Config
Config documentation
Keybindings
Keybindings can be configured in the
keybinds
block.Keys
Keys are defined in a single quoted string, with space delimiting modifier keys.
a
)a
)Left
|Right
|Up
|Down
a
)Backspace
Left
Right
Up
Down
Home
End
PageUp
PageDown
Tab
Delete
Insert
Space
Enter
Esc
Overriding
When configured, keybindings override the default
keybinds
of the application individually (if a certain key was bound in the configuration, it overrides that key in the default configuration).It's possible to explicitly unbind a key:
It's also possible to use the special
clear-defaults=true
attribute either globally or in a specific mode:Shared
There are three special node types that can be used when defining keybindings:
CLI actions
CLI actions documentation
Zellij has a CLI interface that can be used to send actions to the current session.It's also possible to send actions to another accessible session:
Possible actions
Note: only the basic actions are specified here, most actions have additional capabilities. See their
--help
for more info, eg.zellij action new-pane --help
close-pane
: Close the focused paneclose-tab
: Close the current tabdump-screen
: Dumps the pane scrollback to a fileedit
: Open the specified file in a new zellij pane with your default EDITORedit-scrollback
: Open the pane scrollback in your default editorfocus-next-pane
: Change focus to the next panefocus-previous-pane
: Change focus to the previous panego-to-next-tab
: Go to the next tabgo-to-previous-tab
: Go to the previous tabgo-to-tab
: Go to tab with index [index]half-page-scroll-down
: Scroll down half page in focus panehalf-page-scroll-up
: Scroll up half page in focus panehelp
: Print this message or the help of the given subcommand(s)move-focus
: Move the focused pane in the specified direction. [right|left|up|down]move-focus-or-tab
: Move focus to the pane or tab (if on screen edge) in the specified direction [right|left|up|down]move-pane
: Change the location of the focused pane in the specified direction [right|left|up|down]new-pane
: Open a new pane in the specified direction [right|left|up|down] If no direction is specified, will try to use the biggest available spacenew-tab
: Create a new tab, optionally with a specified tab layout and namepage-scroll-down
: Scroll down one page in focus panepage-scroll-up
: Scroll up one page in focus panequit
: Quit Zellijrename-pane
: Renames the focused panerename-tab
: Renames the focused paneresize
: Resize the focused pane in the specified direction. [right|left|up|down|+|-]scroll-down
: Scroll down in focus panescroll-to-bottom
: Scroll down to bottom in focus panescroll-up
: Scroll up in the focused panesearch-input
: Search for Stringsearch-next
: Focus on next search occurrencesearch-previous
: Focus on previous search occurrenceswitch-mode
: Switch input mode of all connected clients [locked|pane|tab|resize|move|search|session]toggle-active-sync-tab
: Toggle between sending text commands to all panes on the current tab and normal modetoggle-floating-panes
: Toggle the visibility of all fdirectionloating panes in the current Tab, open one if none existtoggle-fullscreen
: Toggle between fullscreen focus pane and normal layouttoggle-pane-embed-or-floating
: Embed focused pane if floating or float focused pane if embeddedtoggle-pane-frames
: Toggle frames around panes in the UIundo-rename-pane
: Remove a previously set pane nameundo-rename-tab
: Remove a previously set tab namewrite
: Write bytes to the terminalwrite-chars
: Write characters to the terminalZellij run
It's possible to run a specific command inside a new Zellij pane from the CLI.
It's also possible to send the command to another accessible session:
For more information, see
zellij command --help
In Zellij's shell integrations, this is aliased to
zp
(zellij pane) for tiled panes andzpf
(zellij pane floating) for floating panes.eg.
zp tail -f /tmp/my-log.log
(TODO: link to shell integrations section)Zellij edit
It's possible to open an editor pane (eg. vim) from the command line.
Note: The editor must be set in the
EDITOR
orVISUAL
environment variables, or alternatively in thescrollback_editor
configuration parameter.It's also possible to open an editor in another accessible session:
For more information, see
zellij edit --help
In Zellij's shell integrations, this is aliased to
zo
(zellij open) for tiled panes andzof
(zellij open floating) for floating panes.eg.
zof src/main.rs
(TODO: link to shell integrations section)