michaeldfallen / git-radar Goto Github PK
View Code? Open in Web Editor NEWA heads up display for git
License: MIT License
A heads up display for git
License: MIT License
Hi,
first: thank you very much for the great tool.
second: I'm quite a newbie regarding shell prompt customization, so ...
now: I'm using OS X terminal app with dark solarized color theme, see https://github.com/tomislav/osx-terminal.app-colors-solarized. Within this theme, the "git(...)" part of git-radar ist colored black with bad contrast to the dark backround. I haven't found a way to customize that. Can it be customized?
This may be related to issue #40 and #57 .
Again thanks for the great work!
Regards
Stefan
Hi,
I'm using bash in my terminals and I face very often a weird issue that happens when I change to another work branch and make a pull. The first time the pull fails showing the error message below. The second time works fine.
$ git checkout devel
$ (𝘮 ← 272 devel) 2A git pull
Ubuntu 13.10 ssh-pty
error: Ref refs/remotes/origin/devel is at 8d5945183d93bb831fc58f71b0801b97fbb2076f but expected 91981363fc49ccc92b7519695f08e7c9e41ec181
From xxxxxx:proyect/app
! 9198136..8d59451 devel -> origin/devel (unable to update local ref)
$ (𝘮 ← 274 devel 2↓) 2A git pull
Ubuntu 13.10 ssh-pty
Updating 9198136..8d59451
Fast-forward
...
Can anybody point me out in the right direction about what the problem is? Thanks.
I am receiving this error:
sed: 1: "s/%{\(\([^%^{^}]*\)\:\) ...": bad flag in substitute command: 't'
This is my PS1:
export PS1="\[\033[01;32m\]\j\[\033[00m\]|\[\033[01;34m\]\W\[\033[00m\] \$(git-radar --bash --fetch) 🍉 ";
This error occurs sporadically in and out of tmux, and I fully acknowledge that some other utility may be causing it. Any help is appreciated.
Cheers 🍻
Currently origin/master
is hardcoded. To support git-flow we should really be able to configure this. A file in .git that contains the ref to target (defaulted to origin/master
if not present) should do the job.
This is a request to remove the space prefix of the output of git-radar
. This would give more flexibility to theme builders over where the output can be placed. It would also be more consistent, because there's no padding at the end of the output.
First of all, git-radar
is brilliant! 😃 Great Work!
I do notice that the prompt could get quite long, depending of the status of your git project. For example: git:(upstream ⚡long-named-branch xx) 1A 1D1M 1A1
could be a little long.
I wonder if people would be interested in adding an optional --minimal
arg to the git-radar
command, so when present, both the git:
and the remote commits status (i.e: upstream ⚡
) will not be shown. The reason i'm suggesting to hide the remote commits status is because i don't rely on it 100% of the time, but again, I'm curious to see what others think.
The other option could be for this --minimal
arg to only hide the git:
part, and then have another arg --no-remote-status
that, if present, will hide the remote commits status part of the prompt.
I will be more than happy to help implementing this feature. Let me know what you think.
Cheers!
...would be nice
Hi, Linux user here.
Some of the characters are now showing up correctly. Particularly the "Remote commits status" arrow icons:
My font is currently "Adobe Source Pro for Powerline", although I already tried a couple others, including non-Powerline fonts.
I'm not sure if this is some issue with git-radar, or with my own system, but maybe someone here has had this problem before?
Would you be willing to share some of the prompts you have in the README.md
For example this one
https://raw.githubusercontent.com/michaeldfallen/git-radar/master/images/detailed.png
Thank you
I'm brand new to zsh, so this may be my mistake. The zsh examples given in the README and the usage message don't work for me, so I experimented and ended up using this:
%$(git-radar --zsh --fetch)
which results in this:
%{ git:(𝘮 34 ⇄ 65 feature/AUD-1140) 2A
note the '%{' at the beginning, which seems to be caused by the git-radar command, not by some other part of the prompt variable (this is a minimal working example). For what it's worth, within a longer PROMPT variable, the %{ is colored according to the preceding color escape codes.
This is on OS X Yosemite, in iTerm.
As sargas pointed out in Issue #10 : The unittests are not passing through when called in a ubuntu bash shell.
This should be fixed before continuing development on new features.
I have tried fixing the tests, so that they would work on my ubuntu terminal. Could someone test them out on OSX?
The radar's local and remote commits can be slow, on heavy repos it can be very slow. We could use git hooks to only calculate the local and remote commits each time push, fetch, pull, commit etc events occur.
The precalculated strings could then be read from files in the .git
folder quite quickly on each render.
This is a quick fix: line 80 of git-radar
nohup $dot/fetch.sh 2>/dev/null &
Redirecting stderr
Hey,
I installed via Homebrew and added the export path and got the following error when running source ~/.zshrc
nohup: redirecting stderr to stdout
radar displays:
git:(upstream ⚡ detached@4560144) 2M 56A
I expected git:(upstream ⚡ my_tagName)
Is this assumption wrong?
Thanks for git-radar!
The "git:" label is useful for like a day, then it becomes visual noise. Can it be suppressed?
$ git-radar --bash
fatal: ambiguous argument './master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument './master...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
git:(some-branch)
pushing the branch remotely fixes the issue
$ git push -u origin some-branch
Total 0 (delta 0), reused 0 (delta 0)
To [email protected]:PagerDuty/web.git
* [new branch] some-branch -> some-branch
Branch some-branch set up to track remote branch some-branch from origin.
$ git-radar --bash
git:(some-branch)
Some info about my system stats:
os x el capitan version 10.11.1
git version 2.6.2
Upgrade issue:
==> Upgrading michaeldfallen/formula/git-radar
==> Downloading https://github.com/michaeldfallen/git-radar/releases/download/v0.6/git-radar-0.6.tar.gz
==> Downloading from https://github-cloud.s3.amazonaws.com/releases/30383524/479733a6-8a17-11e5-9757-048ccc020cf6.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20151113%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-D
Error: SHA1 mismatch
Expected: 8a2ba434134413e16d83a6dd8d98ba5e1d3ac782a0719abc27fc6feef6ca5a82
Actual: 27c9ebfe8470851099d3f4efe65370cf00c9b58d
Archive: /Library/Caches/Homebrew/git-radar-0.6.tar.gz
To retry an incomplete download, remove the file above.
Winnetou-iMac:~ mati$
Nice PS1
hack. This is definitely the fanciest one I've seen for git. So I want to help you improve it.
My question is this: do blank lines appear in the terminal if you hold down the enter key? That means the time to optimize is now. The name of the game is to drive down latency so that never happens.
Here's some code I wrote for mine own .bashrc
file that you can use. It uses bash builtins to determine the git root and the current branch. This way you only need like 5 or so system calls, rather than the 182 you'd need to run the git command: strace -f git symbolic-ref --short HEAD |& wc -l
I've found that this is really helpful not only from the user experience standpoint (fast is better than slow) but also in situations where IO gets pwnd or you run out of processes. git might not run at all and you need builtins to save the system.
The only tradeoff with these functions is that it leaves garbage files behind in /tmp
. It's assumed that a cron job exists to purge those occasionally. /etc/cron.daily/tmpreaper
comes standard on Debian systems.
# Caches last directory for which `jartps1_gitdir_find` failed.
export JARTPS1_GITDIR_TMP="$(mktemp --suffix=-jartps1-gitdir)"
################################################################################
# Swiftly determine name of current Git branch.
#
# Arguments:
# None
# Returns:
# 0 on success, storing result to ${jartps1_gitbranch}.
# 1 if ${PWD} isn't inside a Git repo.
# Globals:
# jartps1_gitbranch - Used to store result.
################################################################################
jartps1_gitbranch_find() {
if jartps1_gitdir_find; then
local head
if read head <"${jartps1_gitdir}/.git/HEAD" &>/dev/null; then
if [[ "${head}" =~ refs/heads/(.+) ]]; then
jartps1_gitbranch="${BASH_REMATCH[1]}"
else
jartps1_gitbranch="${head##*/}"
fi
if [[ "${jartps1_gitbranch}" != "" ]]; then
return 0
fi
fi
fi
return 1
}
################################################################################
# Swiftly locate root of current Git repository.
#
# This is the fastest possible solution. Rather than the naïve approach of
# executing the git command (which could take hundreds of milliseconds), this
# routine launches no processes and only requires a few stat() system calls. In
# some cases it can avoid lookup or cache the result.
#
# Arguments:
# dir - Optional, defaults to ${PWD}
# Returns:
# 0 on success, storing result to ${jartps1_gitdir}.
# 1 if dir isn't inside a Git repo.
# Globals:
# jartps1_gitdir - Used to store result.
# JARTPS1_GITDIR_TMP - Temp file used to cache last failed search.
################################################################################
jartps1_gitdir_find() {
local dir="$1"
if [[ -z "${dir}" ]]; then
dir="${PWD}"
case "${dir}" in
/) return 1 ;;
/home/${USER}) return 1 ;;
esac
if [[ -f "${JARTPS1_GITDIR_TMP}" ]]; then
local notgit
if read notgit <"${JARTPS1_GITDIR_TMP}" &>/dev/null; then
if [[ "${dir}" == "${notgit}" ]]; then
return 1
fi
fi
fi
fi
if [[ -d "${dir}/.git" ]]; then
jartps1_gitdir="${dir}"
else
local parent="${dir%/*}"
if [[ -z "${parent}" ]]; then
printf "%s" "$PWD" >"${JARTPS1_GITDIR_TMP}"
return 1
fi
jartps1_gitdir_find "${parent}"
fi
}
There's one discrepancy from git status --short
that annoys me, and that is that untracked files are marked with ??
in the status, but with a grey A
in git-radar
. I understand that that is because there's a relation between untracked and added files, but I'd rather have the output resemble what I see in git status --short
, which matches my mental model better. Is there a way to change the individual symbols?
If a branch isn't set upstream (i.e. isn't tracking a remote branch) then the remote_branch_name returns ``and so all theremote_ahead..
/`remote_behind..` calls return nothing.
That isn't particularly informative. Would be useful to have a function that tells you if a local branch is tracking and can be used in the prompt to identify a branch that is local only.
Why go to the trouble of installing a package through homebrew in order to customize PS1
? What about Linux users?
Consider instead maintaining a "binary" release file in your repository. You could just have a makefile cat everything together, so long as you remember to run it before each commit.
Then your install instructions could be simple and transparent:
wget -O ~/.git-radar.bashrc https://raw.githubusercontent.com/michaeldfallen/git-radar/master/.git-radar.bashrc
sed -i -e '/.git-radar.bashrc/d' ~/.bashrc
echo source ~/.git-radar.bashrc >>~/.bashrc
source ~/.git-radar.bashrc
Just made a new lightweight stable version of git-radar 0.3.2
Only for Mac OS X and for fish/bash
Link: https://github.com/bogem/mini-git-radar
Hope, someone like it
I am trying to ignore the remote status section (as checking my current branch against origin/master isn't helpful for me). I can't seem to get the flag to work:
export PS1='[$NC]\u@\h:[$Red]\w[$NC]$(git-radar --bash --fetch --no-remote-status) $ '
Still gives me this output:
mike@compy:~/Development/project git:(𝘮 7 ⇄ 4 develop)
Thanks!
Hi,
When I add export PS1="\W\$(~/git-radar/git-radar --bash) "
to my .bashrc I get the following:
py_ \[\]git:(\[\]\[\]master\[\]\[\])\[\] 3\[\]M\[\] 59\[\]A\[\]
Where py_
is my current direcotry.
When I add export PS1="\W$(~/git-radar/git-radar --bash) "
it shows the correct format but no longer updates. I suppose this has to do with static executation and lazy evaluation of bash for PS1 and thus not the correct way of using your script.
I will appreciate if you could help.
P.s the package is fantastic. Cannot wait to use it and possibly contribute back.
Uninstalled git-radar on osx 10.8.5 using "brew uninstall michaeldfallen/formula/git-radar"
After every command i run in the shell i get the following message
"-bash: /usr/local/bin/git-radar: No such file or directory"
I'm trying to replace my home grown version with git-radar
but I'm having problems with background colors. Here's what my old theme looks like:
And here's what I see using git-radar
:
Here's how I set the background and the text from git-radar
:
echo "%{$BG[019]%}$(git-radar --zsh --fetch) "
So, it looks like the background is set on the branch name? Is this correct?
git checkout -b some-feature
git push -u some-remote some-feature
git push some-remote :some-feature
yields the following output whenever git-radar
is called on the branch with the missing upstream:
fatal: ambiguous argument 'some-remote/some-feature...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Fatal: ambiguous argument 'some-remote/some-feature...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
The example is a silly chain of three commands to elicit this behavior, but I don't think having tracked branches deleted from remotes is an uncommon occurrence.
Sometimes I forget that I have something stashed, and later come back to the problem and wind up rewriting things. Would be nice to see that I have something stashed. Maybe just a single character, or a number 1-9+ of how many things are stashed.
Gg
Hi, I have come across something... it seems that (for me at least) it does not fetch every 5 minutes, but rather, almost immediately.
I notice in the code that there is a record timestamp function that creates a file in the .git directory of a repo, but mine is empty, and with a quick scan of the code I could not find a place that put anything in that file, and thus the timestamp is possible just nothing so the script thinks it needs to fetch always.
Has anyone else seen this?
Not that I am complaining, because I think I like it this way anyways, but just something I observed.
Noticed in issue #28, copy and pasting the example usage from https://github.com/michaeldfallen/git-radar/blame/master/README.md#L38 will cause the prompt to only execute once, when the PROMPT var is first set.
We should rewrite the Readme to include correct instructions and highlight the importance of escaping execution in the same way as in the bash instructions.
Tried all three of the above at the top of my .zshrc
Each one just places the text in the parentheses in my prompt but doesn't apply the prompt settings. What configuration am I missing here?
Brew install is successful
Disabled oh-my-zsh framework.
restarted terminal after each attempt with the different settings above.
It's like it's not actually running the code. A couple times (not every time) actually running $git-radar --zsh
returned the the prompt color code that should be applied in the prompt.
Had trouble in using the zsh in ubuntu, the command that includes the PROMPT does not work does not seem to boot
I'm using zsh on El Capitan (sorry).
export PROMPT="$(git-radar --zsh --fetch) "
renders the prompt once and then doesn't update. The suggested way to get the subexpression to re-evaluate on each prompt render (export PROMPT="\$(git-radar --zsh --fetch)"
) renders the raw characters $(git-radar --zsh --fetch)
for me.
I've tried using backticks and
Thanks for making radar and for responding to the issues so well! This one is not urgent at all, so a point in the right direction whenever you've got time would be great 😄
The grep
in git bash for Windows does not support the -o
option. grep -o
plays a pretty big part in the (staged|conflicted|unstaged|untracked)_status
, which means that, on Windows, using git-radar results in the following message repeated about 20 times.
grep: invalid option -- o
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
The prompt doesn't update when I change branches, make changes, or anything else. However, it does work when using bash. The only way I can get it to change is by opening a new shell window or running exec $SHELL
.
When you have two branches point to the same upstream branch you get the following message:
fatal: ambiguous argument 'origin/branch
origin/branch...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'origin/branch
origin/branch...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
due to the remote_branch_name
function having trouble finding which branch to follow
I'm on Windows 7 / cygwin / oh-my-zsh. How can I install git radar?
Documentation says export PROMPT="$PROMPT$(git-radar --zsh --fetch) "
but $git-radar
says export PROMPT="%1/%\$(git-radar --zsh --fetch) "
Is one of these not right?
Haven't been able to get either to work. Have tried sourcing .zshrc, reseting, restarting terminal and machine. Not recieving errors though.
Cheers!
Hello and thanks for amazing work!
All works fine except line length: since you don't escape color codes via additional pair of "[" and "]", macos thinks that prompt has much greater length than actually is and wraps text being entered early.
What else do I need to add into my ~/.bashrc to fix this issue? Maybe some flag or general setting is required?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.