From 5d003733593f09e21ec0aafb16f7c796b908ea62 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 25 Jun 2015 12:23:37 +0200 Subject: [PATCH] Added check for OS X update_terminal_cwd This will allow to open new terminal tabs in the same directory as the current terminal. Uses the fact that plugins are loaded after the selected theme. Themes often manipulate the $PROMPT_COMMAND variable. Implementation inspired by the pathmunge function. --- plugins/available/osx.plugin.bash | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index c690e8f3..8628ca3c 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -1,6 +1,15 @@ cite about-plugin about-plugin 'osx-specific functions' +# OS X: Open new tabs in same directory +if [ $(uname) = "Darwin" ]; then + if type update_terminal_cwd > /dev/null 2>&1 ; then + if ! [[ $PROMPT_COMMAND =~ (^|;)update_terminal_cwd($|;) ]] ; then + export PROMPT_COMMAND="update_terminal_cwd;$PROMPT_COMMAND" + fi + fi +fi + function tab() { about 'opens a new terminal tab' group 'osx'