dotfiles/packages/scripts/spawn-term/spawn-term
Christopher Mühl 786af32daf
Publish my config
This is the result of ~100 commits to my NixOS config. Since I haven't
always used `agenix-rekey`, this is another initial commit so that none
of the secrets in my git history are leaked
2025-07-30 23:36:39 +02:00

27 lines
456 B
Bash
Executable file

#!/usr/bin/env bash
ACTIVE_WINDOW=$(hyprctl activewindow -j )
ACTIVE_CLASS=$(echo "$ACTIVE_WINDOW" | jq -r .initialClass)
if [[ $ACTIVE_CLASS == *"kitty"* ]]
then
PID=$(echo "$ACTIVE_WINDOW" | jq -r .pid)
if [[ "$PID" == "" ]]
then
kitty
fi
CHILD_PID=$(pgrep -P "$PID" | tail -1)
if [[ "$PID" == "" ]]
then
kitty
fi
pushd "/proc/${CHILD_PID}/cwd"
SHELL_CWD=$(pwd -P)
popd
kitty --directory "$SHELL_CWD"
else
kitty
fi