plugins/preview-tui | 13 +++++++++---- diff --git a/plugins/preview-tui b/plugins/preview-tui index a7b1101aa6c0245cc26194ce329f5a82e7a4bf92..86260eb289f49cb42483f60210ced5e4268378a7 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -182,6 +182,13 @@ cat "$NNN_FIFO" |\ while read -r selection ; do preview_file "$selection" done + + # Restoring the previous layout for kitty users. This will only work for + # kitty >= 0.18.0. + if [ "$TERMINAL" = "kitty" ]; then + kitty @ last-used-layout --no-response >/dev/null 2>&1 + fi + exit 0 fi @@ -191,7 +198,8 @@ if [ "$SPLIT" = "v" ]; then SPLIT="h"; else SPLIT="v"; fi tmux split-window -e "NNN_FIFO=$NNN_FIFO" -e "PREVIEW_MODE=1" -d"$SPLIT" "$0" "$1" elif [ "$TERMINAL" = "kitty" ]; then - # Setting the layout for the new window. + # Setting the layout for the new window. It will be restored after the + # script ends. kitty @ goto-layout splits >/dev/null # Trying to use kitty's integrated window management as the split window. @@ -202,9 +210,6 @@ --cwd "$PWD" --env "PATH=$PATH" --env "NNN_FIFO=$NNN_FIFO" \ --env "PREVIEW_MODE=1" --env "PAGER=$PAGER" \ --env "USE_SCOPE=$USE_SCOPE" --env "SPLIT=$SPLIT" \ --location "${SPLIT}split" "$0" "$1" >/dev/null - - # Restoring the previous layout. - kitty @ last-used-layout --no-response >/dev/null 2>&1 else PREVIEW_MODE=1 $TERMINAL -e "$0" "$1" & fi