Live data from Hacker News

A heads up display for git

github.com

31–40 of 62 posts

Re: A heads up display for git

#31

This is neat and I think there's a lot of potential here. As with many information displays, though, it's critical to consider what the most important information to convey is and how to effectively do it. My main question is around the use of color. I'd argue the error states - conflicts, diverging branches, etc - should be the ones in red, since those are the issues you want to call the most attention to. Getting r…

Thanks! Glad you like it. Fair point on the `git:(`, it's mostly a hold over from robbyrussells oh-my-zsh theme (which inspired me to make the first version of this about 2 years ago ( https://github.com/michaeldfallen/oh-my-zsh/blob/master/them... ). The entire thing is composable so if you want a prompt without those bits just fork and modify: https://github.com/michaeldfallen/git-radar/blob/master/prom... . Or sho…

You could try to make more of the prompt configurable but that just seems like more work for yourself. It may be that our goals are just different.

I'm totally on board with you about trying not to leave things untracked. It seems like things always accumulate that shouldn't be committed but are useful; I should probably just move them to a different root folder.

Here's the prompt I use[0], adapted from some shell script I found online somewhere. I'm not going to link to the code because it's kind of ugly but it is up on my github.

A clean repository is subdued but readable blue. When there are unstaged changes there's a red plus, and staged changes get a green plus (some of both is yellow). Any branch discrepancies at all are shown by writing the branch name in bold red.

I don't try to give myself too much information, making the assumption that you'll have to do some digging to get enough detail to actually do anything about the situation.

[0]: http://i.imgur.com/sttMpfQ.png

Re: A heads up display for git

#32

This is neat and I think there's a lot of potential here. As with many information displays, though, it's critical to consider what the most important information to convey is and how to effectively do it. My main question is around the use of color. I'd argue the error states - conflicts, diverging branches, etc - should be the ones in red, since those are the issues you want to call the most attention to. Getting r…

Thanks! Glad you like it. Fair point on the `git:(`, it's mostly a hold over from robbyrussells oh-my-zsh theme (which inspired me to make the first version of this about 2 years ago ( https://github.com/michaeldfallen/oh-my-zsh/blob/master/them... ). The entire thing is composable so if you want a prompt without those bits just fork and modify: https://github.com/michaeldfallen/git-radar/blob/master/prom... . Or sho…

This is good stuff: I've already added it to my dotfiles git repo that sync between machines I use. I would like, however, an option to turn off the 'git:' bit. Chartjunk is exactly what it is :)

Re: A heads up display for git

#34
post #23

You could negate the need for a --bash or --zsh flag by checking $SHELL: echo $SHELL | egrep -o '[a-z]+$' It might also make sense to bundle everything under one file as well. While I'd normally advocate separating code into smaller and more manageable files, a single file shell script would be more convenient to install and would require less disk reads per every prompt call. Looks good though. I'm definitely going…

I did try that on a previous tool Butler ( https://github.com/michaeldfallen/butler ) but I found that some shells don't actually set `$SHELL`.

Some don't, but $SHELL is generally accurate enough for Bash and Zsh.

You can also check the shell by checking the PID:

  ps -p $$
But then you need to do extra output parsing plus, obviously, ps each time you output $PS1. Which is going to be a little overkill for this project since it's only Zsh and Bash you're wanting to capture and you can always have fallback support for those flags when automatic detection fails.

Re: A heads up display for git

#36
post #32

Earlier quoted context omitted.

Thanks! Glad you like it. Fair point on the `git:(`, it's mostly a hold over from robbyrussells oh-my-zsh theme (which inspired me to make the first version of this about 2 years ago ( https://github.com/michaeldfallen/oh-my-zsh/blob/master/them... ). The entire thing is composable so if you want a prompt without those bits just fork and modify: https://github.com/michaeldfallen/git-radar/blob/master/prom... . Or sho…

This is good stuff: I've already added it to my dotfiles git repo that sync between machines I use. I would like, however, an option to turn off the 'git:' bit. Chartjunk is exactly what it is :)

Will do. I'll add the ability to change the prefix/suffix.

Re: A heads up display for git

#38
post #17
post #9

I use a modified version of mislav's git prompt https://gist.github.com/mislav/1712320 which is pretty minimal but usually enough for me. For when I have to wrangle lots of files at once (like during interactive rebase to clean up history before push) I have a git watch alias that shows a high-level overview of changes that refreshes with inotify: [alias] watch = "!clear;inotifywait --quiet -mr -e modify,move,create,…

How would this need to be changed to work on osx?

It's less efficient, but you could just use a timed solution like watch:

   watch -n 2 'git status --short; git --no-pager diff --shortstat;'

Re: A heads up display for git

#39
post #9

I use a modified version of mislav's git prompt https://gist.github.com/mislav/1712320 which is pretty minimal but usually enough for me. For when I have to wrangle lots of files at once (like during interactive rebase to clean up history before push) I have a git watch alias that shows a high-level overview of changes that refreshes with inotify: [alias] watch = "!clear;inotifywait --quiet -mr -e modify,move,create,…

I like your `git watch` alias! That's very slick.

I like my git prompt to show me my branch name, colored with grey (no changes), red (unsaved changes), or green (staged changes), with the depth of the branch, e.g.:

    gknoy@host:~/dev/foo/[bar-feature:4]$ 

My prompt is based on: https://gist.github.com/tobiassjosten/828432

... but I've made slight modifications:

    # I sometimes have very long branch names.
    # I don't assume it's a hash:
    if [ ${#GIT_BRANCH} -gt 40 ]; then
        # GIT_BRANCH="(no branch)"
	GIT_BRANCH="${GIT_BRANCH:0:40}..."
    fi
and, at the end of `git_prompt`:

    branch_depth=`git rev-list HEAD --not --remotes|wc -l`
    echo "[$git_color$GIT_BRANCH$c_reset:${branch_depth}]"
Post reply on HN