kakounedotcom / connect.kak

Connect a program to Kakoune clients
https://kakoune.org
The Unlicense
88 stars 18 forks source link

unset env variables when session is closed #47

Open basbebe opened 3 years ago

basbebe commented 3 years ago

After unsuccesfully trying to reattach to a session, environment variables should be unset I guess.

alexherbo2 commented 3 years ago

How?

basbebe commented 3 years ago

something like

:attach

#!/bin/sh

# Reattach to the session.
kak -c "$KAKOUNE_SESSION" "$@"

exit_status=$?
if [ $exit_status -ne 0 ] ; then
    unset IN_KAKOUNE_CONNECT
    unset KAKOUNE_SESSION
    unset KAKOUNE_CLIENT
fi

(maybe in an extra function – sorry for not opening a PR)

basbebe commented 3 years ago

or even

exit_status=$?
if [ $exit_status -ne 0 ] ; then
    exit
fi
basbebe commented 3 years ago

probably a :quit function would be a good approach (with alias q)?

and in each function:

exit_status=$?
if [ $exit_status -ne 0 ] ; then
    :quit
fi
basbebe commented 3 years ago

different but related (open new issue or put to trash?):

If a session is killed, kill all related windows:

alexherbo2 commented 3 years ago

I remember @occivink telling the underlying terminal used in the terminal alias doesn’t necessarily expose a PID.

basbebe commented 3 years ago

I remember @occivink telling the underlying terminal used in the terminal alias doesn’t necessarily expose a PID.

then what I had in mind would of course not be feasible without the overhead of loops and hooks or environment variables storing the PIDs.

but nevertheless I would find a :quit function useful which would automatically be invoked when the session is lost.

alexherbo2 commented 3 years ago

What is the content of the :quit command?

basbebe commented 3 years ago

probably just exit.

maybe also a :kill which does :send kill?

But of course both are not necessary for functionality.

alexherbo2 commented 3 years ago

How about @ aliased to :send, so that you can:

@ kill
basbebe commented 3 years ago
@ kill

great!