Skip to content

dmitriy-rs/zellij-smart-sessionizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Zellij Smart Sessionizer

Zellij sessionizer with layout selection capability
Instant Zellij session startup powered by Zoxide and fuzzy finder

zellij smart sessionizer demo

Table of Contents

Key Features

  • Easy to use: Run zs or Ctrl+f in your shell select your project from Zoxide list using fzf or skim, select preferable layout;
  • Usage inside zellij session: It will create a new tab with the selected layout;
  • Attach to the session: Will not ask for layout when the session was previously created;
  • Layout config preview: Layout config preview will be shown using bat if installed or cat as a fallback

Installation

  1. Install all dependencies

    • Zoxide
    • skim or fzf - fuzzy finders, skim has higher priority
    • bat - optional dependency
  2. Clone the repo

git clone https://github.com/demestoss/zellij-smart-sessionizer
cd zellij-smart-sessionizer
  1. Place zellij-smart-sessionizer script in your PATH. One of the ways:
sudo chmod +x ./zellij-smart-sessionizer
sudo ln -s $(echo "$(pwd)/zellij-smart-sessionizer") /usr/bin/zellij-smart-sessionizer
  1. Populate your Zoxide database by simply going into the directories that you want to start the session from. Check Zoxide docs for more info.

  2. (Recommended) I like to create alias for the script to have an ability to easily execute it. Place it into your shell's .rc file:

alias zs="zellij-smart-sessionizer"
  1. (Optional) Create an alias to call this script in your shells .rs config
bindkey -s ^f "zellij-smart-sessionizer^M"

Usage

You just need to type this command in your shell to start a new session

zellij-smart-sessionizer

# or just this command if you have done (5) step of installation process

zs

Or Ctrl+f if you've set up an optional keybinding step

Next will be provided different types of scenarios of the script execution.

Outside of Zellij (session doesn't exist)

You will be offered paths from Zoxide. After selection, it will give you a layout selection for the session if your layout directory is not empty. It uses the LAYOUT DIR path provided to Zellij setup.

After that, it will open a session with a zoxide path's basename and selected layout.

Outside of Zellij (session exists)

You will be offered paths from Zoxide. After selecting a path, the layout step will be skipped and you will be attached to Zellij session.

Inside Zellij

If you run this script inside Zellij you will be offered the same selection steps. But after selection, it will open a new tab with the selected session basename and Layout

Note: Not all layouts will be provided in this case, It's kinda smart and will not provide layouts that contain tabs options inside it, because you cannot create tabs inside the tab.

Usage inside Neovim

I like to have this keymap in my Neovim config to run sessionizer inside floating pane:

vim.keymap.set("n", "<C-f>", ":silent !zellij action new-pane -f -c -- zellij-smart-sessionizer<CR>", { silent = true })

By pressing Ctrl+f inside Neovim you will open floting window with sessionizer script

Passing session name argument

Also, you can provide optional arguments to the script

zellij-smart-sessionizer session-name

# or

zs session-name

It will pick up this argument and will init session with this name instead of the path's basename. It's very useful if you want to have several different sessions that were initialized from the same directory

Quick Tips

I was always strugling with removing directories from Zoxide DB, so I finally found the right solution and want to share it here :)

If you want to remove some paths from your Zoxide DB you can use this simple command:

zoxide remove $(zoxide query -l | fzf -m)

Select options that you want to remove by pressing Tab and they will be deleted from DB

Inspirations

Special thanks to this repos:

License

MIT

About

Instant Zellij session startup with layout selection capability

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages