1
0
Fork 0
dotfiles/.local/bin/kak-slatectx

33 lines
773 B
Bash
Executable File

#!/bin/bash
# This script sets kakounes default session id to the slatectx context
use_slatectx_id="true"
# Fist determine if we even want to set an id
for i in "$@" ; do
case "$i" in
-s|-c) use_slatectx_id="" ; break ;;
--) break ;;
esac
done
if [ -n "$use_slatectx_id" ] ; then
# Make sure we have some variables we need
[ -z "$SLATECTX_CONTEXT_NAME" ] && SLATECTX_CONTEXT_NAME="$(slatectx-get-context-name)"
[ -z "$XDG_RUNTIME_DIR" ] && XDG_RUNTIME_DIR="/run/user/$(id -u)"
# We don't want to run into dead sockets
kak -clear
# Switch based on the need for a server instance
if [[ -e "$XDG_RUNTIME_DIR/kakoune/$SLATECTX_CONTEXT_NAME" ]] ; then
kak -c "$SLATECTX_CONTEXT_NAME" "$@"
else
kak -s "$SLATECTX_CONTEXT_NAME" "$@"
fi
else
kak "$@"
fi