+
+ restore_terminal_title
+}
+
+#hmmm: to go below.
+### takes out the first few carriage returns that are in the input.
+##function squash_first_few_crs()
+##{
+ ##i=0
+ ##while read input_text; do
+ ##i=$((i+1))
+ ##if [ $i -le 5 ]; then
+ ##echo -n "$input_text "
+ ##else
+ ##echo $input_text
+ ##fi
+ ##done
+ ##if [ $i -le 3 ]; then
+ ### if we're still squashing eols, make sure we don't leave them hanging.
+ ##echo
+ ##fi
+##}
+
+#hmmm: the below are git specific and should be named that way.
+
+function all_branch_names()
+{
+ echo "$(git branch -vv | cut -d ' ' -f2)"
+}
+
+# a helpful method that reports the git branch for the current directory's
+# git repository.
+function my_branch_name()
+{
+ echo "$(git branch -vv | grep '\*' | cut -d ' ' -f2)"
+}
+
+#this had a -> in it at one point for not matching, didn't it?
+# this reports the upstream branch for the current repo.
+##function parent_branch_name()
+##{
+ ##echo "$(git branch -vv | grep \* | cut -d ' ' -f2)"
+##}
+
+# reports the status of the branch by echoing one of these values:
+# okay: up to date and everything is good.
+# needs_pull: this branch needs to be pulled from origins.
+# needs_push: there are unsaved changes on this branch to push to remote store.
+# diverged: the branches diverged and are going to need a merge.
+# reference: https://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
+function check_branch_state()
+{
+ local branch="$1"; shift
+
+ if [ -z "$branch" ]; then
+ echo "No branch was passed to check branch state."
+ return 1
+ fi
+
+ local to_return=120 # unknown issue.
+
+ local local_branch=$(git rev-parse @)
+ local remote_branch=$(git rev-parse "$branch")
+ local merge_base=$(git merge-base @ "$branch")
+
+ local to_echo=
+ if [ "$local_branch" == "$remote_branch" ]; then
+ to_echo="okay"
+ elif [ "$local_branch" == "$merge_base" ]; then
+ to_echo="needs_pull"
+ elif [ "$remote_branch" == "$merge_base" ]; then
+ to_echo="needs_push"
+ else
+ to_echo="diverged"
+ fi
+
+ echo -n "$to_echo"
+
+ return $to_return
+}
+
+# only shows the branch state if it's not okay.
+# note that this is not the same as a conditional branch (ha ha).
+function show_branch_conditionally()
+{
+ local this_branch="$1"; shift
+
+ local state=$(check_branch_state "$this_branch")
+ if [ "$state" != "okay" ]; then
+ echo "=> branch '$this_branch' state is not clean: $state"