Closed ckp95 closed 2 years ago
Why not just run it through kitty? If window manager supports running GUI programs, then just run a new kitty process directly.
Write a script, fd to fzf, get the selected item and call xdg open.
keyboard shortcut -> kitty /path/to/my-launcher.zsh
That creates two windows, a blank one (I assume that's the "controlling" window?) and the one with fzf inside it. I just want the fzf window.
There is no such thing as a control window. For example, run kitty --config=NONE vim
in the terminal and try it.
For example, run kitty --config=NONE vim in the terminal and try it.
I don't understand what point you're making.
https://sw.kovidgoyal.net/kitty/invocation/
When running the executable with kitty parameters, only a new process and an OS window will be opened. (No session configuration)
https://sw.kovidgoyal.net/kitty/remote-control/
If you want to use remote control. There has to be a kitty process already running, listening to the socket, and then sending commands to this already running process via remote commands.
In your script, the first kitty command will run at least one blank window and will not exit.
You need to make sure that kitty is running and that a unix socket exists when you use kitty @ --to to send remote commands .
I still don't get it. If kitty has to be already running, then that means there will be two windows opened when I run the keyboard shortcut. I don't want two windows, I just want one.
Okay it turns out I was overcomplicating this. I don't even need to use the remote control feature at all. All I have to do is bind a keyboard shortcut to:
#! /usr/bin/zsh
tmp=$(mktemp -d)
trap 'rm -rf $tmp' EXIT
kitty sh -c "fd --follow --color=always . $HOME/me/ | sed -E 's#^(.{10})$HOME#\1~#g' | fzf -e --layout=reverse --ansi | sed -E 's#^~#$HOME#g' >$tmp/stdout"
choice="$(< $tmp/stdout)"
if [[ ! -z $choice ]] then
xdg-open $choice
fi
Is this what you meant before with your vim example?
Is this what you meant before with your vim example?
Yes, maybe it could be a bit simpler, without the need for temporary file.
What I'm trying to do
Make a file searcher and launcher powered by kitty and fzf. It would launch a kitty window running a script that calls fzf, in which I search for a file, and then when I press enter, it launches the file using xdg-open. This would be invoked via a keyboard shortcut in my window manager, not from a pre-existing kitty window.
What I have so far
This works, when run from an existing kitty window:
It is based on code found in issue #2440 .
The problem
However, when I try to bind this script to a shortcut in my window manager, it does not work. Nothing appears. When I inspect the error output sent to
/tmp/kitty-error
, it says:I searched for the error code and found this issue talking about something similar: #2426 . It says I need to:
But I don't understand how I'm meant to apply that to my problem. I only have a
kitty @
invocation, there isn't akitty
on its own. I read the documentation at the end of here, which says:So I tried to follow that and wrote this:
But this didn't work either. When launched from the keyboard shortcut, a kitty window appears but with nothing running in it. The error file reads:
I don't understand what I'm supposed to do. What am I doing wrong?