Giter Site home page Giter Site logo

git-radar's Issues

Remove the space before the output

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.

Installation with ohmyzsh

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!

Make it faster using builtins

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
}

Easier install

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

How to adjust coloring of "git:"

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

Any modifications required for Mac OS?

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?

illustration

Problems zsh ubuntu

Had trouble in using the zsh in ubuntu, the command that includes the PROMPT does not work does not seem to boot

Extraneous characters displayed in zsh output

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.

`grep -o` not available in git bash for Windows

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.

Add an argument to make the prompt more minimalistic (shorter)

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!

have to pull twice to update a work branch

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.

  • First pull
$ 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)
  • Second pull
$ (𝘮 ← 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.

Colors

A better color palette (or a collection of) to support existing terminal color themes would be very much appreciated.

no-remote-status being ignored?

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!

Fetches not every 5 minutes?

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.

Identify a branch that isn't set upstream

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.

Show whether anything is stashed

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.

0.6 upgrade issue

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

################################################################## 100.0%

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$

Unittests not working in linux

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?

Here is the link to the fixed tests.

Possible to change character for untracked files?

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?

weird characters show up with git-radar on mac os x

This only happens in 1 of my repositories, the other ones work just fine.
It used to work, but I don't know what has changed since then.
Let me know how I can help figure this out, thanks!

$ git-radar --bash --fetch
 git:(master) 1��

Here is a screenshot:

http://i.imgur.com/oKpSY06.png

Does git-radar set background colors?

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:

screen shot 2015-08-26 at 17 53 45

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?

Prompt not loading in zsh

export PROMPT="$PROMPT$(git-radar --zsh) "

export PROMPT="%1/%$(git-radar --zsh --fetch) "

export PROMPT="$(git-radar --zsh)"

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.

odd sed error on branches named with multiple / characters

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 🍻

Optionally hide "git:"

Thanks for git-radar!

The "git:" label is useful for like a day, then it becomes visual noise. Can it be suppressed?

OSX Bash: White space being added before branch-name

Hey thanks for git-radar — It feels it's going to really boost my productivity here scanning through changes.

I have tried to install it and somehow and getting some white space before the branch name, any ideas?

Thanks in advance

PS1="(\$(git-radar --bash))$"

screen shot 2015-09-03 at 09 30 20

redirecting on OSX

Hey,

I installed via Homebrew and added the export path and got the following error when running source ~/.zshrc

nohup: redirecting stderr to stdout

Bugs in new version

2015-10-15 16 14 07

  1. Prompt starts with new line
  2. Colors don't display correct

Shell: fish 2.2.0

fatal error messages with git-radar on local untracked branches

$ 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

Duplicate branches pointing to same upstream

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

Use hooks to speed up prompt

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.

Unhandled git error when a tracked upstream branch is removed

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.

Some arrow characters are not showing up

Hi, Linux user here.

Some of the characters are now showing up correctly. Particularly the "Remote commits status" arrow icons:

screenshot from 2015-09-01 12-03-12

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?

escaping `$` prevents subexpression evaluation

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 $'$(…)' to evaluate the sub-expression but none have worked so far.

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 😄

brackets showing up instead of normal prompt representation

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.

Prompt not updating - OSX - zsh

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.