Skip to content

About

A floating terminal for Neovim that is already running: instant toggle, four styles (centered glass, Quake drop-down, side drawer, capsule) and zsh/bash/fish shell integration that shows your folder and failed commands

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

glassterm.nvim

A floating terminal that is already running when you press the key.

toggle the terminal, run something, hide it, zoom

Press Alt+t and a shell appears over your code in about 4 ms, because nothing starts. glassterm keeps the shell alive in a hidden buffer and only shows or hides a window.

Install

With lazy.nvim

{ "skhan75/glassterm.nvim", lazy = false, opts = {} }

On macOS your terminal has to send Option as Alt. Ghostty wants macos-option-as-alt = left, kitty wants macos_option_as_alt left, and iTerm2 calls it "Esc+".

Keys and commands

Key or command What it does
Alt+t Show the terminal, or hide it if you are in it
Alt+z Grow it to the full editor and back
2Alt+t A second terminal
:Glassterm style drop Switch shape
:Glassterm send make test Run something, or send lines with :'<,'>Glassterm send
:Glassterm rerun Run your last command again without opening the terminal

Leave terminal mode the usual way with Ctrl+\ Ctrl+n.

Four shapes

Pick one in opts, or switch any time with :Glassterm style drawer.

glass drop
glass drop
drawer capsule
drawer capsule

It knows your shell

The title follows cd. A failed command turns the border red. :Glassterm rerun runs your last command again and tells you how it went, while you stay in your code.

shell integration

glassterm adds a small hook to the zsh, bash and fish shells it starts. Your own shell files are never touched.

Options

Defaults
require("glassterm").setup({
    style = "glass", -- "glass", "drop", "drawer" or "capsule"
    shell = nil, -- nil uses your 'shell'
    prewarm = { enabled = true, delay_ms = 1000 },
    hide_on_leave = true, -- hide it when you go back to your code
    close_on_exit = true,
    integration = { enabled = true, notify_on_failure = true },
    ui = { hints = true },
    keys = {
        toggle = "<M-t>",
        zoom = "<M-z>",
        send = false, -- try "<leader>ts"
        rerun = false, -- try "<leader>tr"
    },
    styles = { -- 1 or less is a fraction of the editor, more is cells
        glass = { width = 0.86, height = 0.80 },
        drop = { height = 0.42 },
        drawer = { width = 0.44, side = "right" },
        capsule = { width = 76, height = 12, row = 0.26 },
    },
})

Colors follow your theme. Everything links to the usual float groups, so GlasstermBorder is FloatBorder unless you say otherwise. With a transparent colorscheme the float is the same glass as your editor.

Run :checkhealth glassterm to see whether your shell is hooked up.

Speed

About 4 ms per toggle on a bare setup, and about 8 ms with a full config, from keypress to finished redraw. Starting a fresh zsh with oh-my-zsh takes around 1.9 s on the same machine, and that is the wait pre-starting removes. Measure it yourself with make bench.

How it is different

Other floating terminals create the shell the first time you toggle them, so the first open of a session waits for your shell to start. Mine is 1.9 s of zsh. glassterm starts it in the background a second after Neovim does, so every toggle including the first one is instant.

It also reads OSC 7 and OSC 133, so it knows the working directory, when a command starts and finishes, and what it exited with. That is what rerun and the directory sync are built on, instead of guessing from the scrollback.

Questions

Alt and t does nothing on macOS. Your terminal is sending Option as a character. See the install notes above.

My TermOpen autocommand runs startinsert. Does pre-starting throw my editor into insert mode? No. glassterm holds TermOpen back until the float first opens, then runs it there.

Alt and t inside another terminal buffer toggles glassterm. That is on purpose, one key everywhere. Change keys.toggle if you want Alt and t inside terminals.

Development

make test runs the tests. make bench measures the toggle. make demo records these GIFs with VHS.

License

MIT

About

A floating terminal for Neovim that is already running: instant toggle, four styles (centered glass, Quake drop-down, side drawer, capsule) and zsh/bash/fish shell integration that shows your folder and failed commands

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages