From afa8bcc43760358c059d3ec064f98c6046dfd02b Mon Sep 17 00:00:00 2001 From: Midgard <2885-Midgard@users.noreply.framagit.org> Date: Wed, 18 Dec 2024 20:07:13 +0100 Subject: [PATCH] [terminal.sh] Instructions about terminal window title setting --- i3/terminal.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/i3/terminal.sh b/i3/terminal.sh index b9c9318..50a4347 100755 --- a/i3/terminal.sh +++ b/i3/terminal.sh @@ -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'