Last active
September 1, 2022 07:36
-
-
Save sinewalker/a8ca548bb8a341b1c947202cc08cb1fe to your computer and use it in GitHub Desktop.
gitmux filter to replace 'origin' with a symbol for the git host.
This file contains 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
#!/usr/bin/env bash | |
# Wrapper for gitmux to change some strings in ways that it doesn't | |
# allow for. Also replace 'origin' with a symbol for the git host. | |
WORKING_COPY=${1} | |
[[ -d ${WORKING_COPY} ]] || exit 1 | |
pushd $WORKING_COPY &> /dev/null | |
STATUS=$(git status) &> /dev/null || exit 2 | |
URL=$(git config --get remote.origin.url) &> /dev/null | |
if [[ "${STATUS}" =~ "No commits yet" ]] ; then | |
BRANCH="[no commits yet]" | |
else | |
BRANCH=$(echo ${STATUS} | awk '/On branch/ {print $3}') | |
fi | |
case ${URL} in | |
*"bitbucket"*) GITHOST="" ;; | |
*"github"*) GITHOST="" ;; | |
*"lab"*) GITHOST="" ;; | |
*) GITHOST="" ;; | |
esac | |
popd &> /dev/null | |
gitmux -cfg ~/.gitmux.conf ${WORKING_COPY} \ | |
| sed "s/origin/${GITHOST}/" \ | |
| sed "s/${BRANCH}//2" \ | |
| tr -d '/' |
Install this script and gitmux on your $PATH
, and then add this to ~/.tmux.conf
:
set -g status-right '#(_gitmux_filter.sh "#{pane_current_path}")'
(or you could use -ag
instead of -g
, to append gitmux to your existing status-right
global elements)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original: in my bashing project on GitLab
Also see an example .gitmux.conf