Start new terminals with a working directory based on current active terminal

Co-authored-by: @halilozercan
Closes #835
This commit is contained in:
David Heinemeier Hansson 2025-08-22 15:55:48 +02:00
parent 4a1888af8f
commit 2cca02699a
3 changed files with 10 additions and 1 deletions

6
bin/omarchy-cmd-terminal-cwd Executable file
View File

@ -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"

View File

@ -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

3
migrations/1755870033.sh Normal file
View File

@ -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