aboutsummaryrefslogtreecommitdiff
path: root/segments/vcs_others.sh
diff options
context:
space:
mode:
authorCody Hiar <chiar@hybridforge.com>2015-08-12 12:06:23 -0600
committerCody Hiar <chiar@hybridforge.com>2015-08-12 12:06:23 -0600
commit07fc2644a237187dd4c5680e88f4adadbf533603 (patch)
treebb6335e180df48c5a6f0b893312857d36ad470f7 /segments/vcs_others.sh
Initial commit of the working files
Diffstat (limited to 'segments/vcs_others.sh')
-rwxr-xr-xsegments/vcs_others.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/segments/vcs_others.sh b/segments/vcs_others.sh
new file mode 100755
index 0000000..0911468
--- /dev/null
+++ b/segments/vcs_others.sh
@@ -0,0 +1,51 @@
+# This checks if the current branch is ahead of or behind the remote branch with which it is tracked.
+
+# Source lib to get the function get_tmux_pwd
+source "${TMUX_POWERLINE_DIR_LIB}/tmux_adapter.sh"
+
+other_symbol="⋯ "
+
+run_segment() {
+ tmux_path=$(get_tmux_cwd)
+ cd "$tmux_path"
+ stats=""
+ if [ -n "${git_stats=$(__parse_git_stats)}" ]; then
+ stats="$git_stats"
+ elif [ -n "${svn_stats=$(__parse_svn_stats)}" ]; then
+ stats="$svn_stats"
+ elif [ -n "${hg_stats=$(__parse_hg_stats)}" ]; then
+ stats="$hg_stats"
+ fi
+ if [[ -n "$stats" && $stats -gt 0 ]]; then
+ echo "${other_symbol}${stats}"
+ fi
+ return 0
+}
+
+__parse_git_stats(){
+ type git >/dev/null 2>&1
+ if [ "$?" -ne 0 ]; then
+ return
+ fi
+
+ # check if git
+ [[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return
+
+ # return the number of staged items
+ other=$(git ls-files --others --exclude-standard | wc -l)
+ echo $other
+}
+__parse_hg_stats(){
+ type svn >/dev/null 2>&1
+ if [ "$?" -ne 0 ]; then
+ return
+ fi
+ # not yet implemented
+}
+__parse_svn_stats(){
+ type hg >/dev/null 2>&1
+ if [ "$?" -ne 0 ]; then
+ return
+ fi
+ # not yet implemented
+}