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'