[terminal.sh] Instructions about terminal window title setting

This commit is contained in:
Midgard 2024-12-18 20:07:13 +01:00
parent 0c5e2dce04
commit afa8bcc437
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -1,5 +1,14 @@
#!/bin/bash
# If a window with a path in its title is focused, open a terminal with that
# location as working directory. Like this, terminals are opened in the same
# directory as the currently focused one.
#
# Your shell should set the window title correctly, of course. In most common
# terminals this can be achieved with
# printf '\033]2;%s@%s:%s\007' "${USER}" "${HOSTNAME%%.*}" "${PWD}"
# In bash, you can put this printf in your PROMPT_COMMAND.
set -uo pipefail
# A failure in this script should not prevent the terminal from opening
set +e
@ -11,10 +20,6 @@ else
CMD=xfce4-terminal
fi
# If a window with a path in its title is focused, open a terminal with that
# location as working directory. Like this, terminals are opened in the same
# directory as the currently focused one.
focused_window_title() {
if [ -n "${WAYLAND_DISPLAY:-}" ]; then
lswt -j | jq -r '.toplevels | map(select(.activated?))[0].title'