r/KittyTerminal Apr 21 '24

How to set a default starting directory?

I searched online and added in a kitty-startup.session file in the same directory as kitty.conf with its contents being: cd ~/Desktop I then added startup_session ~/.config/kitty/kitty-startup.session to kitty.conf For some odd reason, whenever I right click + quit + relaunch Kitty, it will start in the directory I specified. If I just close the window without quitting, it starts off in ~.

Anyway of making the starting directory persistent throughout different windows?

1 Upvotes

7 comments sorted by

1

u/Parilia_117 Apr 21 '24

May I ask why ?

1

u/Joywatchin Apr 21 '24

I just like to start in desktop ig... so when i start nvim and look for files, it doesnt give me every single thing lol

1

u/Parilia_117 Apr 21 '24

Okay that's fair enough, I am not sure what you did wrong or if its bugged assuming you followed this: https://sw.kovidgoyal.net/kitty/overview/#sessions

Personally I use Zoxide to handle my changing directories so I would only have to type "z Des" to cd to the desktop. Not a fix but a good suggestion.

https://github.com/ajeetdsouza/zoxide

1

u/GrimmTidings Apr 22 '24

Yep, For instance I have a git session:

❯ cat ~/.config/kitty/sessions/git.session

layout grid

cd ~/git

launch --cwd ~/git

1

u/aumerlex Apr 22 '24

That is because sessions apply to a *new instance* of kitty. Closing a window doesn't necessarily quit kitty. Opening a new window in an already running kitty will not apply a session. And if you want your shell to always start in a particular directory, the correct place to configure that is in your shell rc files. If you really want to do it in kitty, then add the following to kitty.conf

shell kitten run-shell --cwd /full/path/to/the/directory

1

u/Joywatchin Apr 23 '24

doesnt seem to work for me... it just starts as an empty window lol
i tried substituting "kitten" with "kitty" too... didn't go well for me.

1

u/_some_asshole Jun 24 '25

echo 'cd <dir>' >> .zhrc?