Created
October 9, 2017 21:15
-
-
Save lomholdt/42da9bae3235122d714e56a6a9aa2bb0 to your computer and use it in GitHub Desktop.
Add git branch to tmux status bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Current path | |
current_path="$(tmux display-message -p -F "#{pane_current_path}")" | |
# get the current branch | |
function get_branch { | |
value=$(cd $current_path; git rev-parse --abbrev-ref HEAD) | |
echo $value | |
} | |
# # Determine if we are in a git repo | |
# function is_git_repo { | |
# if [ -d $current_path/.git ]; then | |
# return 1 | |
# elif [ $(cd $current_path; git rev-parse --is-inside-work-tree) ]; then | |
# return 1 | |
# else | |
# return 0 | |
# fi; | |
# } | |
# if is_git_repo; then | |
# get_branch | |
# else | |
# echo no branch | |
# fi | |
# Determine if we are in a git repo | |
if [ -d $current_path/.git ]; then | |
get_branch | |
elif [ $(cd $current_path; git rev-parse --is-inside-work-tree) ]; then | |
get_branch | |
else | |
echo no branch | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment