From 2cc67fb0d2d5deed3cf4db2a385f44a86ee8a719 Mon Sep 17 00:00:00 2001 From: David Wales Date: Sat, 6 Feb 2016 01:41:06 +1100 Subject: [PATCH 1/2] Speed up bazaar by simulating bzr root with bash The PS1 line took forever (~1s) to display in bzr branches, because bzr is slow. I increased the speed by eliminating the call to bzr, and replacing it with a modified bash script which I found here: http://unix.stackexchange.com/questions/6463/find-searching-in-parent-directories-instead-of-subdirectories --- bash/bash_vcs.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bash/bash_vcs.sh b/bash/bash_vcs.sh index 1616a61..1b966ae 100644 --- a/bash/bash_vcs.sh +++ b/bash/bash_vcs.sh @@ -84,7 +84,15 @@ __prompt_command() { } bzr_dir() { - base_dir=$(bzr root 2>/dev/null) || return 1 + # bzr root is really slow, so we simulate it + # with a bash script I modified frome here: + # http://unix.stackexchange.com/questions/6463/find-searching-in-parent-directories-instead-of-subdirectories + bzr_root=$(pwd -P 2>/dev/null || command pwd) + while [ ! -e "$bzr_root/.bzr" ]; do + bzr_root=${bzr_root%/*} + if [ "$bzr_root" = "" ]; then break; fi + done + base_dir=$bzr_root || return 1 if [ -n "$base_dir" ]; then base_dir=`cd $base_dir; pwd` else @@ -139,4 +147,4 @@ if [ -z "$TM_SUPPORT_PATH"]; then trap 'echo -e "\e]1;$project>$BASH_COMMAND<\007\c"' DEBUG # show currently executing command in tab title ;; esac -fi \ No newline at end of file +fi From 7314c582a95ffec8a49803be0fc3ede7ecc2d951 Mon Sep 17 00:00:00 2001 From: David Wales Date: Mon, 8 Feb 2016 21:50:26 +1100 Subject: [PATCH 2/2] Fix broken bar_dir() function, Improve speed. The previous commit didn't know what to do outside of a bzr repo. This fixes it, and makes it a bit faster. --- bash/bash_vcs.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bash/bash_vcs.sh b/bash/bash_vcs.sh index 1b966ae..ec019a2 100644 --- a/bash/bash_vcs.sh +++ b/bash/bash_vcs.sh @@ -83,16 +83,20 @@ __prompt_command() { alias revert="svn revert" } - bzr_dir() { - # bzr root is really slow, so we simulate it + bzr_base_dir() { + # bzr root is really slow, so we simulate it # with a bash script I modified frome here: # http://unix.stackexchange.com/questions/6463/find-searching-in-parent-directories-instead-of-subdirectories - bzr_root=$(pwd -P 2>/dev/null || command pwd) - while [ ! -e "$bzr_root/.bzr" ]; do - bzr_root=${bzr_root%/*} - if [ "$bzr_root" = "" ]; then break; fi + base_dir=$(pwd -P 2>/dev/null || command pwd) + while [ ! -e "$base_dir/.bzr" ]; do + # delete /* from the end of base_dir + base_dir=${base_dir%/*} + if [ "$base_dir" = "" ]; then return 1; fi done - base_dir=$bzr_root || return 1 + } + + bzr_dir() { + bzr_base_dir || return 1 if [ -n "$base_dir" ]; then base_dir=`cd $base_dir; pwd` else