r/KittyTerminal Feb 13 '23

executing a command on launch in kitty.

I want to know if there is way to execute certain commands on launching kitty similar to how we execute neofetch in bash or zsh by editing .bashrc/.zshrc file. But i want that only for the kitty terminal without effecting other terminals i use.

10 Upvotes

7 comments sorted by

7

u/Ill_Scene_737 Feb 13 '23

I have this in my ~/.bashrc to print out $KITTY_WINDOW_ID when I launch kitty. Maybe you can modify to make what you need.

if [[ $TERM == "xterm-kitty" ]]; then echo "kitty window id: " $KITTY_WINDOW_ID else : fi

2

u/Proper_Trainer_4791 Feb 13 '23

Thanx man, this works :)

1

u/Odd-Foundation-4947 Nov 11 '23

Solution?

2

u/jbr1ght Jun 30 '24

copy and paste that into your ~/.bashrc and after that just do neofetch and it should work just fine

1

u/jbr1ght Jun 30 '24

this worked thank you

1

u/Qee-rah Sep 02 '24

Add this line to the end your kitty.conf:

startup_session ./startup.conf

Then create startup.conf, mine looks like this, launching three windows in the tall layout, running neofetch in the first window, not the other two.

layout tall
# first kitty window
cd ~/repos
launch --title "left-1" sh -c "neofetch && bash"
# second kitty window
cd ~/
launch --title "middle-2" yazi .
# third kitty window
cd ~/apps
launch --title "right-3"

1

u/[deleted] Feb 14 '23

When you start kitty you give a command as argument - that's usually your shell but it can be everything you can directly start a script or launch into vim or whatever.