Skip to content

Commit

Permalink
Use global porcelain if there is one
Browse files Browse the repository at this point in the history
  • Loading branch information
robertgzr committed Oct 11, 2018
1 parent 3b1386e commit f4ae3f1
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions porcelain.tmux
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PORCELAIN_BIN="$CURRENT_DIR/porcelain"

porcelain_status="#($CURRENT_DIR/porcelain -tmux -path '#{pane_current_path}')"
global_porcelain=""
porcelain_status="#($PORCELAIN_BIN -debug -tmux -path '#{pane_current_path}')"
porcelain_interpolation_string="\#{porcelain}"

do_interpolation() {
Expand All @@ -18,17 +20,30 @@ update_tmux_option() {
tmux set-option -gq "$option" "$new_option_value"
}

install() {
update_tmux_option "status-right"
update_tmux_option "status-left"
}

main() {
if ! [[ -f "$CURRENT_DIR/porcelain" ]]
global_porcelain="$(command -v porcelain)"
if [[ -f "$global_porcelain" ]]
then
PORCELAIN_BIN=$global_porcelain
install
exit 0
fi

if ! [[ -f "$PORCELAIN_BIN" ]]
then
curl -sL "$(curl -s https://api.github.com/repos/robertgzr/porcelain/releases/latest | grep "browser_download_url" | grep "$(uname | tr '[:upper:]' '[:lower:]')"| cut -d\" -f4)" |\
tar -C "$CURRENT_DIR" -xzf - porcelain &>/dev/null
fi
# try again
if [[ -f "$CURRENT_DIR/porcelain" ]]
if [[ -f "$PORCELAIN_BIN" ]]
then
update_tmux_option "status-right"
update_tmux_option "status-left"
install
exit 0
fi
}
main

0 comments on commit f4ae3f1

Please sign in to comment.