Skip to content

Instantly share code, notes, and snippets.

@sinewalker
Last active September 1, 2022 07:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinewalker/a8ca548bb8a341b1c947202cc08cb1fe to your computer and use it in GitHub Desktop.
Save sinewalker/a8ca548bb8a341b1c947202cc08cb1fe to your computer and use it in GitHub Desktop.
gitmux filter to replace 'origin' with a symbol for the git host.
#!/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 '/'
@sinewalker
Copy link
Author

sinewalker commented Aug 30, 2022

@sinewalker
Copy link
Author

sinewalker commented Aug 30, 2022

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