Applications
Editing
I do all my editing in kak-shell
from connect.kak to manage sessions. It is inspired by nix-shell from NixOS and the first menu (when you choose a session) by 3mux.
Window management
Sway or Wayfire, and terminal-mode.kak to choose the terminal (tmux, graphical or same terminal window).
Workspace
I use tmux as a workspace, where each session is a window.
[0]
⇒ Console
[1]
⇒ Editor
[2]
⇒ Scratch
For example in [0]
, I have a window for the Rails server and console (two panes in a window), in [1]
the editor for Rails, and [2]
a lf instance connected to the editor in [1]
.
When I switch to another project, I keep [0]
, [1]
and [2]
for the same tasks, but switch the view to the appropriate window in each session (what you can see as tabs in a tmux session).
Searching files
For searching files, :e
, :e <directory>
or :e <a-.>
(to expand to the buffer directory) to search with fzf in the same terminal window (see connect.kak and explore.kak).
map global prompt -docstring 'Expand to the buffer directory' <a-.> '%sh(dirname "$kak_buffile")<a-!>'
For searching buffers, :b
to search with fzf (same plugins).
Exploring files
For exploring files, either lf or Dolphin with :lf
and :dolphin
(from connect.kak); when I click a file, it opens in the client from which :lf
and :dolphin
were run.
I mainly use Dolphin on foreign code for discovering and clicking around.
About the TUI file explorer, I use lf for its client-server architecture and simple interaction with external programs. You don’t have tabs, but you can copy or cut a file from one lf to another lf. lf initializes the server on first launch – all lf are just clients connected to a server. It’s like Kakoune, but automated, and you have a single server. As far as I know, it is the only terminal file manager offering a client-server architecture.
Like Kakoune, it interacts well with external tools, such as fzf.
Example – Jump to location:
cmd fzf-jump ${{ # [path...]
# Select a file under the given or current directory:
path=$(fd . "$@" | fzf --header='Jump to location')
# Assign the command:
if test -f "$path"; then
command=select
elif test -d "$path"; then
command=cd
else
exit 1
fi
# Send the command to the client:
lf -remote "
send $id $command $path
"
}}
map <c-f> fzf-jump
lf documentation
There is some oddities ($f
, $fs
and $fx
could be unified and support different formats for perfect escaping, instead of relying on a filesep
option); block strings are not as robust (multiple levels do not work) and flexible than in Kakoune (you don’t have %arg{n}
to pass values, but typically just do \"$1\"
of the shell inside double quotes (where inside it’s the lf speak), which is not a perfect forwarding).
I tried other file managers too.
One of the most different is Broot. It is like a project drawer (for its tree-style view) with a fzf interface. I see it more like a file selector rather than a file explorer.
The author of lf said on reddit:
The way I see it, terminal managers are like a normal mode for shell. You can assign keys to your commands and execute them easily instead of typing (as in hitting i to open a file in your pager rather than typing less <tab>
).
Broot makes fuzzy searching very easy at the expense of making spatial navigation (therefore exploring) not easy.
While lf has —hjkl— spatial navigation, it can extend its functionalities with fzf or another program to open a file or navigate into deep structures.
I wish I could make a better use of Broot in my workflow, but I didn’t.
See also the last paragraphs of Why Kakoune – What is modal text editing; I think @mawww better captured what I try to express.