summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAlex Leferry 2 <alexherbo2@gmail.com>2020-06-22 00:26:40 +0200
committerAlex Leferry 2 <alexherbo2@gmail.com>2020-06-22 00:26:40 +0200
commit52e8a0db24ffde813a762be05fee1f3879f7997a (patch)
treefac0f6ca9f708706c9510e08bd44dbf2181ea9b7 /bin
parentb42e0713ab94d85c2e6a1cbba58204ecccd2dc80 (diff)
Refactor the way to connect to the same terminal window
Diffstat (limited to 'bin')
-rwxr-xr-xbin/kak-connect21
1 files changed, 7 insertions, 14 deletions
diff --git a/bin/kak-connect b/bin/kak-connect
index 41b589f..9612ee3 100755
--- a/bin/kak-connect
+++ b/bin/kak-connect
@@ -3,7 +3,7 @@
# Environment variables ────────────────────────────────────────────────────────
XDG_DATA_HOME=${XDG_DATA_HOME:-~/.local/share}
-CONNECT_SCRIPT_PATH=$XDG_DATA_HOME/kak/connect/script.sh
+KAKOUNE_CONNECT_SCRIPT=$XDG_DATA_HOME/kak/connect/script.sh
# Main ─────────────────────────────────────────────────────────────────────────
@@ -14,7 +14,7 @@ main() {
edit "$@"
# Try to connect to an existing session from a previous :connect-detach command.
- elif test -t 1 -a -e "$CONNECT_SCRIPT_PATH"; then
+ elif test -t 1 -a -e "$KAKOUNE_CONNECT_SCRIPT"; then
attach
# Create a session and attach if there is a terminal.
@@ -40,19 +40,12 @@ EOF
# connect-detach allows to run CLI commands in the same terminal window.
kak -c "$kak_session" -e "
alias global terminal connect-detach
- set-option global connect_environment %{
- # Unset KAKOUNE_CLIENT when attached to a terminal.
- # Motivation: GUI apps can connect to the client.
- # Example: :connect-shell dolphin
- if test -t 1; then
- KAKOUNE_CLIENT=''
- fi
- }
+ set-option global connect_attach yes
connect-terminal $@
"
# Attach the connect terminal command.
# Act as a “boot loader”.
- if test -e "$CONNECT_SCRIPT_PATH"; then
+ if test -e "$KAKOUNE_CONNECT_SCRIPT"; then
attach
fi
@@ -71,9 +64,9 @@ EOF
# Functions ────────────────────────────────────────────────────────────────────
attach() {
- mv "$CONNECT_SCRIPT_PATH" "$CONNECT_SCRIPT_PATH~"
- sh "$CONNECT_SCRIPT_PATH~"
- rm -f "$CONNECT_SCRIPT_PATH~"
+ mv "$KAKOUNE_CONNECT_SCRIPT" "$KAKOUNE_CONNECT_SCRIPT~"
+ sh "$KAKOUNE_CONNECT_SCRIPT~"
+ rm -f "$KAKOUNE_CONNECT_SCRIPT~"
}
main "$@"