Closed basbebe closed 3 years ago
You can indicate the Kakoune session and client when in a connected terminal.
When connected to a client:
${KAKOUNE_CLIENT}@${KAKOUNE_SESSION}
When connected to a session:
${KAKOUNE_SESSION}
[custom.connect_kak]
command = "echo 'kak:'$KAKOUNE_CLIENT@$KAKOUNE_SESSION"
when = 'test -n "$IN_KAKOUNE_CONNECT"'
description = "Indicates that the current shell is connected to a Kakoune session"
style = "green italic"
In some scenarios, when using the kak-shell
program for example, you can be connected to a session without a client, so you may want to test both cases.
In some scenarios, when using the
kak-shell
program for example, you can be connected to a session without a client, so you may want to test both cases.
When and how would this happen?
[custom.connect_kak]
command = "echo 'kak:'$( test -n \"$KAKOUNE_CLIENT\" && echo $KAKOUNE_CLIENT@)$KAKOUNE_SESSION"
when = 'test -n "$IN_KAKOUNE_CONNECT"'
shell = ["sh", "--norc"]
description = "Indicates that the current shell is connected to a Kakoune session"
style = "green italic"
@basbebe If it’s TOML, I would go with multi-line literal strings or two prompts.
[custom.kakoune_connect_client]
command = 'printf "🐈(${KAKOUNE_CLIENT}@${KAKOUNE_SESSION})"'
when = 'test "$IN_KAKOUNE_CONNECT" = 1 -a -n "$KAKOUNE_SESSION" -a -n "$KAKOUNE_CLIENT"'
shell = ['dash']
description = 'Indicates that the current shell is connected to a Kakoune client'
style = 'green italic'
[custom.kakoune_connect_session]
command = 'printf "🐈(${KAKOUNE_SESSION})"'
when = 'test "$IN_KAKOUNE_CONNECT" = 1 -a -n "$KAKOUNE_SESSION" -a -z "$KAKOUNE_CLIENT"'
shell = ['dash']
description = 'Indicates that the current shell is connected to a Kakoune session'
style = 'green italic'
Or
command = '''
if [ "$KAKOUNE_CLIENT" ]; then
...
else
...
fi
'''
I prefer the first because command
is not intended for testing.
Just added Starship to the Custom prompt section.
one question still though: when and how would I only be connected to a session but not a client?
In some scenarios, when using the
kak-shell
program for example, you can be connected to a session without a client, so you may want to test both cases.When and how would this happen?
one question still though: when and how would I only be connected to a session but not a client?
@alexherbo2 (because I always seem to get connected to client0)
kak-shell
Sorry, I'm just curious how this would happen with kak-shell
since I always get connected to client0
…
You don’t have a client yet when invoking kak-shell
.
For other clients than client0
, try to open a connected terminal from the client1
.
Ah!
So the variable client0
means that there is no client yet?
Maybe an error from a fixed value. I don’t recall the source. Ideally I would like to remove the client variable to always use the last used client.
🤔
This works fine in starship prompt: