Connect - Simple but Amazing

This little plugin hits way above it’s weight class.

@alexherbo2 described it:

You can use :connect to create a new terminal with [e]dit , [b]uffer and VISUAL , EDITOR connected to the client.

If you open a file using the shell command edit or an application using the default editor, the file will be opened in the client from where :connect was executed.

You can also open a buffer by using the buffer command (or its alias b ). With no argument, buffer will list the available buffers.

4 Likes

Just have been revisiting the code. Now works with yank-ring.kak.

Code is :ok_hand: now. More robust and way simpler (especially the yank ring, as I was seeking for more composability, and a less alien interface).

Requires the terminal forwarding correction (which just has been merged) to work properly.

Thanks @alexherbo2, its hard work just keeping up with you :smile:.
A workaround for osx find command with fzy just add file fzy.kak to Alex’s modules.
connect.kak/rc/modules/fzy.kak

provide-module connect-fzy %{
  require-module connect
  define-command fzy-files -params .. -file-completion -docstring 'Open selected files with fzy' %{
    connect-terminal sh -c %{
      edit $(find . -type f "$@" | fzy)
    } -- %arg{@}
  }
  define-command fzy-buffers -params ..1 -buffer-completion -docstring 'Open selected buffers with fzy' %{
    connect-terminal sh -c %{
      buffer $(buffer | grep -F "$1" | fzy)
    } -- %arg{@}
  }
  alias global fzy fzy-files
}
# <https://github.com/alexherbo2/connect.kak>
plug "alexherbo2/connect.kak" %{
  require-module connect-fzy
}

Great job Alex, thanks. Bye.

find can be very slow on large structures. That is why I use fd.

cool thanks for the info and its on the brew install fd list so why not give it a run. Thanks Alex.

Confirmed :muscle:

provide-module connect-fzy %{
  require-module connect
  define-command fzy-files -params .. -file-completion -docstring 'Open selected files with fzy' %{
    connect-terminal sh -c %{
      edit $(fd --type file . "$@" | fzy)
    } -- %arg{@}
  }
  define-command fzy-buffers -params ..1 -buffer-completion -docstring 'Open selected buffers with fzy' %{
    connect-terminal sh -c %{
      buffer $(buffer | grep -F "$1" | fzy)
    } -- %arg{@}
  }
  alias global fzy fzy-files
}