kakounedotcom / connect.kak

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

report connect.kak in starship prompt #46

Closed basbebe closed 3 years ago

basbebe commented 3 years ago

This works fine in starship prompt:

[custom.connect_kak]
command = "echo 'kak '"
when = 'test -n "$IN_KAKOUNE_CONNECT"'
description = "Indicates that the current shell is connected to a Kakoune session"
style = "green italic"
alexherbo2 commented 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}
basbebe commented 3 years ago
[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"
Bildschirmfoto 2021-02-02 um 13 57 21
alexherbo2 commented 3 years ago

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.

basbebe commented 3 years ago

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?

basbebe commented 3 years ago
[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"
alexherbo2 commented 3 years ago

@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.

alexherbo2 commented 3 years ago

Just added Starship to the Custom prompt section.

basbebe commented 3 years ago

one question still though: when and how would I only be connected to a session but not a client?

basbebe commented 3 years ago

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)

alexherbo2 commented 3 years ago
kak-shell
basbebe commented 3 years ago

Sorry, I'm just curious how this would happen with kak-shell since I always get connected to client0

alexherbo2 commented 3 years ago

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.

basbebe commented 3 years ago

Ah! So the variable client0 means that there is no client yet?

alexherbo2 commented 3 years ago

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.

basbebe commented 3 years ago

🤔