-# Display the command about to be executed
-# This must go at the end of bashrc to avoid running the trap on commands in the bashrc
+# Preserve working directory when opening new terminals
+# This depends on /etc/profile/vte.sh
+function record_terminal_cwd {
+ [ "$(type -t __vte_osc7)" = "function" ] && __vte_osc7 || true
+}
+
+function prompt_command {
+ print_title_prompt
+ record_terminal_cwd
+}
+PROMPT_COMMAND=prompt_command
+
+# Display the command about to be executed. This must go at the end of the
+# bashrc to avoid running the trap on commands in the bashrc