From 2cca02699afffff9a38bdab9de1d456484c05273 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 22 Aug 2025 15:55:48 +0200 Subject: [PATCH] Start new terminals with a working directory based on current active terminal Co-authored-by: @halilozercan Closes #835 --- bin/omarchy-cmd-terminal-cwd | 6 ++++++ config/hypr/bindings.conf | 2 +- migrations/1755870033.sh | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 bin/omarchy-cmd-terminal-cwd create mode 100644 migrations/1755870033.sh diff --git a/bin/omarchy-cmd-terminal-cwd b/bin/omarchy-cmd-terminal-cwd new file mode 100755 index 00000000..86143d01 --- /dev/null +++ b/bin/omarchy-cmd-terminal-cwd @@ -0,0 +1,6 @@ +#!/bin/bash + +# Go from current active terminal to its child shell process and run cwd there +terminal_pid=$(hyprctl activewindow | awk '/pid:/ {print $2}') +shell_pid=$(pgrep -P "$terminal_pid" | head -n1) +readlink -f "/proc/$shell_pid/cwd" 2>/dev/null || echo "$HOME" diff --git a/config/hypr/bindings.conf b/config/hypr/bindings.conf index 0adb0e26..182cc85d 100644 --- a/config/hypr/bindings.conf +++ b/config/hypr/bindings.conf @@ -3,7 +3,7 @@ $terminal = uwsm app -- alacritty $browser = uwsm app -- chromium --new-window $webapp = $browser --app -bindd = SUPER, return, Terminal, exec, $terminal +bindd = SUPER, return, Terminal, exec, $terminal --working-directory $(omarchy-cmd-terminal-cwd) bindd = SUPER, F, File manager, exec, uwsm app -- nautilus --new-window bindd = SUPER, B, Browser, exec, $browser bindd = SUPER, M, Music, exec, uwsm app -- spotify diff --git a/migrations/1755870033.sh b/migrations/1755870033.sh new file mode 100644 index 00000000..e1a0be0d --- /dev/null +++ b/migrations/1755870033.sh @@ -0,0 +1,3 @@ +echo "Use current terminal shell cwd for new terminal working directories" + +sed -i 's|bindd = SUPER, return, Terminal, exec, \$terminal|bindd = SUPER, return, Terminal, exec, $terminal --working-directory $(omarchy-cmd-terminal-cwd)|' ~/.config/hypr/bindings.conf