Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ all:

install: $(SOURCES)
@echo 'Installing in ' $(PREFIX)/bin
cp git-radar $(PREFIX)/bin
cp radar-base.sh $(PREFIX)/bin
cp prompt.zsh $(PREFIX)/bin
cp prompt.bash $(PREFIX)/bin
cp fetch.sh $(PREFIX)/bin
cp git-radar $(PREFIX)/bin/
cp radar-base.sh $(PREFIX)/bin/
cp prompt.zsh $(PREFIX)/bin/
cp prompt.bash $(PREFIX)/bin/
cp prompt-tmux.bash $(PREFIX)/bin/
cp fetch.sh $(PREFIX)/bin/


develop: $(SOURCES)
Expand All @@ -32,4 +33,5 @@ develop: $(SOURCES)
ln -s $(PWD)/radar-base.sh $(PREFIX)/bin/radar-base.sh
ln -s $(PWD)/prompt.zsh $(PREFIX)/bin/prompt.zsh
ln -s $(PWD)/prompt.bash $(PREFIX)/bin/prompt.bash
ln -s $(PWD)/prompt-tmux.bash $(PREFIX)/bin/prompt-tmux.bash
ln -s $(PWD)/fetch.sh $(PREFIX)/bin/fetch.sh
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ function fish_prompt
end
```

**Tmux**

Add to your `.tmux.conf`
```
set -g status-left "#(git-radar --tmux)"
```

## Features

### Files status
Expand Down
7 changes: 6 additions & 1 deletion git-radar
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ if [[ -z $@ ]]; then

echo ""
echo "usage:"
echo " git-radar [--zsh|--bash|--fish] [--fetch]"
echo " git-radar [--zsh|--bash|--fish|--tmux] [--fetch]"
echo ""
echo " --fetch # Fetches your repo asynchronously in the background every 5 mins"
echo " --zsh # Output prompt using Zsh style color characters"
echo " --bash # Output prompt using Bash style color characters"
echo " --fish # Output prompt using fish style color characters"
echo " --tmux # Output prompt using tmux style color codes"
echo ""
echo "Bash example:"
echo " export PS1=\"\\W\\\$(git-radar --bash --fetch) \""
Expand Down Expand Up @@ -103,4 +104,8 @@ while [[ $# > 0 ]];do
if [[ "$command" == "--bash" || "$command" == "--fish" ]]; then
$dot/prompt.bash $args
fi

if [[ "$command" == "--tmux" ]]; then
$dot/prompt-tmux.bash $args
fi
done
10 changes: 10 additions & 0 deletions prompt-tmux.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /usr/bin/env bash

dot="$(cd "$(dirname "$0")"; pwd)"
args=$@
source "$dot/radar-base.sh"

if is_repo; then
prepare_tmux_colors
render_prompt
fi
39 changes: 39 additions & 0 deletions radar-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,45 @@ prepare_zsh_colors() {
RESET_COLOR_STASH="%{${GIT_RADAR_COLOR_STASH:-$reset_color}%}"
}

prepare_tmux_colors() {
if [ -f "$rcfile_path/.gitradarrc.zsh" ]; then
source "$rcfile_path/.gitradarrc.zsh"
elif [ -f "$rcfile_path/.gitradarrc" ]; then
source "$rcfile_path/.gitradarrc"
fi

PRINT_F_OPTION="%s"

COLOR_REMOTE_AHEAD="${GIT_RADAR_COLOR_REMOTE_AHEAD:-#[fg=green]}"
COLOR_REMOTE_BEHIND="${GIT_RADAR_COLOR_REMOTE_BEHIND:-#[fg=red]}"
COLOR_REMOTE_DIVERGED="${GIT_RADAR_COLOR_REMOTE_DIVERGED:-#[fg=yellow]}"
COLOR_REMOTE_NOT_UPSTREAM="${GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM:-#[fg=red]}"

COLOR_LOCAL_AHEAD="${GIT_RADAR_COLOR_LOCAL_AHEAD:-#[fg=green]}"
COLOR_LOCAL_BEHIND="${GIT_RADAR_COLOR_LOCAL_BEHIND:-#[fg=red]}"
COLOR_LOCAL_DIVERGED="${GIT_RADAR_COLOR_LOCAL_DIVERGED:-#[fg=yellow]}"

COLOR_CHANGES_STAGED="${GIT_RADAR_COLOR_CHANGES_STAGED:-#[fg=green]}"
COLOR_CHANGES_UNSTAGED="${GIT_RADAR_COLOR_CHANGES_UNSTAGED:-#[fg=red]}"
COLOR_CHANGES_CONFLICTED="${GIT_RADAR_COLOR_CHANGES_CONFLICTED:-#[fg=yellow]}"
COLOR_CHANGES_UNTRACKED="${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-#[fg=white]}"

COLOR_STASH="${GIT_RADAR_COLOR_STASH:-#[fg=yellow]}"

local italic_m="$(printf '\xF0\x9D\x98\xAE')"

COLOR_BRANCH="${GIT_RADAR_COLOR_BRANCH:-#[fg=default]}"
MASTER_SYMBOL="${GIT_RADAR_MASTER_SYMBOL:-"#[fg=default]$italic_m#[fg=default]"}"

PROMPT_FORMAT="${GIT_RADAR_FORMAT:-" #[fg=black,bright]git:(#[fg=default]%{remote: }%{branch}%{ :local}#[fg=black,bright])#[fg=default]%{ :stash}%{ :changes}"}"

RESET_COLOR_LOCAL="${GIT_RADAR_COLOR_LOCAL_RESET:-#[fg=default]}"
RESET_COLOR_REMOTE="${GIT_RADAR_COLOR_REMOTE_RESET:-#[fg=default]}"
RESET_COLOR_CHANGES="${GIT_RADAR_COLOR_CHANGES_RESET:-#[fg=default]}"
RESET_COLOR_BRANCH="${GIT_RADAR_COLOR_BRANCH_RESET:-#[fg=default]}"
RESET_COLOR_STASH="${GIT_RADAR_COLOR_STASH:-#[fg=default]}"
}

in_current_dir() {
local wd="$(pwd)"
if [[ "$wd" == $cwd ]]; then
Expand Down
4 changes: 3 additions & 1 deletion test-radar-base.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

scriptDir="$(cd "$(dirname "$0")"; pwd)"

source "$scriptDir/radar-base.sh"
Expand Down Expand Up @@ -25,4 +27,4 @@ test_show_remote_status() {
assertFalse $?
}

. ./shunit/shunit2
. ./shunit/shunit2