Say I have a window in kitty and press ctrl+shift+enter to open a new window.
The new window always uses ~/ as current working directory. I'd like the new window to use the same working directory that the last window used.
Is this possible?
Say I have a window in kitty and press ctrl+shift+enter to open a new window.
The new window always uses ~/ as current working directory. I'd like the new window to use the same working directory that the last window used.
Is this possible?
In your kitty.conf, instead of using map ctrl+shift+enter new_window, use map ctrl+shift+enter new_window_with_cwd.
Couldn't find this in the documentation but the author mentions it in this issue.
According to the documentation:
You can open a new window with the current working directory set to the working directory of the current window using:
map ctrl+alt+enter launch --cwd=current
Works for me in Lubuntu 20.4:
~$ kitty --version
kitty 0.23.1 created by Kovid Goyal
~$ ack 'map ctrl\+shift\+enter' .config/kitty/
.config/kitty/kitty.conf
27:map ctrl+shift+enter launch --cwd=current
You could save $PWD into a file and in your .bashrc change to the corresponding folder.
The following code is not a complete implementation but a proof-of-concept (which contains issues (e.g.: it does not handle parameters for cd)).
in .bashrc add following lines:
save_and_change_folder() {
if [[ -d "$PWD/$1" ]]; then
echo "$PWD/$1" > cat /home/<user>/.last_folder_visited
fi
cd "$1"
}
alias cd="save_and_change_folder"
if [[ -e "/home/<user>/.last_folder_visited" ]]; then
cd "$(cat /home/<user>/.last_folder_visited)"
fi