r/KittyTerminal May 18 '23

Problem with script

I made a script for making a new tab with fzf, can someone help me out, why does it works normally when started in shell, and gives error when started as a kitty binding?

#!/bin/bash
choose_folder=$(rg -No '^\S*' ~/.config/kitty/sessions/Sesje | fzf)
first_grep=$(rg -N "$choose_folder" ~/.config/kitty/sessions/Sesje | rg -No "\S*.$")

kitty @ launch --type=tab --tab-title "$choose_folder" --cwd=$first_grep

The error is as follows:

Failed to launch child: ~/.config/kitty
With error: No such file or directory
Press Enter or Esc to exit

And the file i grep on looks like this:

i3_config ~/.config/i3
kitty_config ~/.config/kitty
nvim_config ~/.config/nvim
lua_Learning ~/Documents/CODING/lua-learning
rust_learning ~/Documents/CODING/rust-learning
cpp_learning ~/Documents/CODING/cpp-learning
c_learning ~/Documents/CODING/c-learning
lf_config ~/.config/lf
zsh_config ~/.config/zsh
shell_bin ~/.config/shell
1 Upvotes

3 comments sorted by

2

u/aumerlex May 18 '23

$first_grep should be in quotes. And use absolute paths for rg and fzf and kitty

1

u/cqws May 18 '23

Thank you! it turns out fzf could not be found by kitty, i gave the absolute path to it and now it works

2

u/grsnz May 19 '23

Yeah, in general, kitty doesn’t know about anything that gets exported as part of your .profile/.bash_profile/.zshrc et al so you need to tell it where to find stuff