Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Latest commit

 

History

History
80 lines (57 loc) · 1.75 KB

recipes.md

File metadata and controls

80 lines (57 loc) · 1.75 KB

Recipes

Working with headless sessions with kak-shell

kak-shell kanto :attach lets you run a client connected to a session, just like the plain kak -c <session-name>. But with kak-shell kanto :attach, you can create a new named session which starts in headless mode, which is very useful for detaching and reattaching continually.

Therefore, kak-shell kanto :attach replaces kak -c <session-name> and kak -d -s <session-name> and can serve to spawn a client in whatever situation you are.

Tip: Alias kak-shell to ks and connect to a session with ks kanto a.

Custom prompt

You can modify your shell prompt to notify you whenever you are connected to a session.

Example – for Bash:

PS1='$(test "$IN_KAKOUNE_CONNECT" && printf 🐈)$ '

Available variables are:

  • IN_KAKOUNE_CONNECT (1 when true)
  • KAKOUNE_SESSION
  • KAKOUNE_CLIENT

Change directory

In complement to :cd! which syncs the client to your current working directory, you can do the opposite.

Add to your bashrc:

if [ "$IN_KAKOUNE_CONNECT" = 1 ]; then
  alias :cd='cd `:pwd`'
  alias :cd?='cd `:bwd`'
fi

Turn Kakoune into an IDE

define-command ide -params 0..1 -docstring 'ide [session-name]: Turn Kakoune into an IDE' %{
  # Session name
  try %{
    rename-session %arg{1}
  }

  # Main client
  rename-client main
  set-option global jumpclient main

  # Tools client
  new %{
    rename-client tools
    set-option global toolsclient tools
  }

  # Docs client
  new %{
    rename-client docs
    set-option global docsclient docs
  }

  # Project drawer
  dolphin

  # Git
  > lazygit

  # Terminal
  >
}