5 ms·
A heads up display for git
- r3bl 11y agoLooks very promising! Thanks, we really missed something like this in Git.
- TsiCClawOfLight 11y agoI find the ZSH git extension to work very well.
- devrelm 11y agoIs that configurable? That is to say, can I change what's printed to the prompt to add more info like # of files added/removed/modified? I looked into it a little bit it looked hard-coded.
- lorenzhs 11y agoyeah it's pretty configurable, the syntax to do so is rather ugly though. I'm using it like this: https://gist.github.com/lorenzhs/c8b442ce831f0211f3d8 https://gist.github.com/lorenzhs/c8b442ce831f0211f3d8 which shows me whether I have staged and unstaged changes, the current branch and commit, rebase/... status, etc. I don't remember from where I got this config, it's a mix of things I found online.
- devrelm 11y agoInteresting, thanks!
- michaelallen 11y agoThanks :-) It's just something I've been using for a while so very tailored to my needs. YMMV.
- zerolinesofcode 11y agoYou could have called it GitHud ;-)
- zvikara 11y agoAlready taken: https://github.com/kristjan/githud https://github.com/kristjan/githud
- nathancahill 11y agoBy a 3 year old project with 5 stars..
- noalt 11y agohttps://github.com/dahlbyk/posh-git https://github.com/dahlbyk/posh-git has had something similar for awhile - very useful!
- devrelm 11y agoPush Git is great! I've been looking for a comparable solution for *nix for a while. Zsh's git completion/prompt just showing the branch and dirty state isn't enough.
- avar 11y agoConsider sending these changes upstream to contrib/completion/git-prompt.sh in git.git. It already has a lot of toggles for adjusting the prompt. These things you've added could be added as options.
- leni536 11y agoI use something similar for my bash prompt: https://github.com/xtrementl/dev-bash-git-ps1 https://github.com/xtrementl/dev-bash-git-ps1 I wonder if this one is any faster. Waiting for a bash prompt in large repos can be frustrating.
- brandonwamboldt 11y agoI added logic to mine to check for a .noprompt file and disable the git part of my bash prompt as I generally want it enabled, but a few large repos are too slow with it. You could do something similar, I'm sure.
- leni536 11y agoI wonder if an asynchronous approach could be implemented. Like starting the git status and the likes in a separate process and killing it after a certain timeout if it takes too long. While I like that there is a .noprompt feature it's mainly a workaround. Maybe there could be a toggle feature where the user can turn on and off the git prompt on demand, wouldn't be hard to implement. Maybe I will start hacking on it, I have some ideas to optimize it further.
- anishathalye 11y agoIt can be done, and it actually works quite well. See this post for a demo + code: http://www.anishathalye.com/2015/02/07/an-asynchronous-shell-prompt/ http://www.anishathalye.com/2015/02/07/an-asynchronous-shell...
- leni536 11y agoWell this is awesome, thanks for the link.
- an_ko 11y agoI use a modified version of mislav's git prompt https://gist.github.com/mislav/1712320 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,delete --format \"%f %e\" @/.git . | \ while read file; do \ clear;\ git status --short;\ git --no-pager diff --shortstat;\ done;" I leave that running in a visible terminal window. It's more verbose than a prompt and reduces the need for constant git status sanity-checking. Maybe useful for someone.
- TheRealWatson 11y agoI'm going to steal this, thanks. I'll probably make it a script file instead of an alias, though.
- couchand 11y agoPost the Gist when you're done, please?
- mendelk 11y agoHow would this need to be changed to work on osx?
- ianlevesque 11y agoJust need to replace inotifywait with an FSEvents-based change watcher.
- sulam 11y agowatchman (https://github.com/facebook/watchman https://github.com/facebook/watchman) is cross platform.
- _djo_ 11y ago
- mallamanis 11y agoI use https://github.com/magicmonty/bash-git-prompt https://github.com/magicmonty/bash-git-prompt which I also like. It seems to present less information than this one though
- deleted 11y ago[deleted]
- lorenzfx 11y agoI use zsh-vcs-prompt [0], which also supports hg and svn. [0] https://github.com/yonchu/zsh-vcs-prompt https://github.com/yonchu/zsh-vcs-prompt
- opsunit 11y agoliquidprompt https://github.com/nojhan/liquidprompt https://github.com/nojhan/liquidprompt is another viable alternative.
- laumars 11y agoYou 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 to use this on my dev boxes.
- michaelallen 11y agoI did try that on a previous tool Butler (https://github.com/michaeldfallen/butler https://github.com/michaeldfallen/butler) but I found that some shells don't actually set `$SHELL`.
- laumars 11y agoSome 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.
- metasean 11y agoFor anyone interested in putting together their own version, I customized my bash terminal (including git related info) using the following resources: - Mikko Nylén's comment in http://web.archive.org/web/20130127054804/http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt http://web.archive.org/web/20130127054804/http://asemanfar.c... - http://stackoverflow.com/questions/8120553/bash-profile-setting-not-working-for-path-ps1 http://stackoverflow.com/questions/8120553/bash-profile-sett... - http://volnitsky.com/project/git-prompt/ http://volnitsky.com/project/git-prompt/ - http://misc.flogisoft.com/bash/tip_colors_and_formatting http://misc.flogisoft.com/bash/tip_colors_and_formatting - http://tldp.org/LDP/abs/html/string-manipulation.html http://tldp.org/LDP/abs/html/string-manipulation.html - http://www.botsko.net/blog/2010/03/16/git-status-in-command-line/ http://www.botsko.net/blog/2010/03/16/git-status-in-command-...
- oalders 11y agoI use oh-my-git for a similar purpose. https://github.com/arialdomartini/oh-my-git https://github.com/arialdomartini/oh-my-git Took some wrangling to get the fonts to work, but I find it to be quite helpful. The README is especially nice.
- Shebanator 11y agoThe comic-book-style intro on that page is awesome!
- chmike 11y agoWouldn't custom fonts lead to a problem when using ssh ?
- oalders 11y agoI just got the fonts working in iTerm2 and after that I didn't have any issues that I recall.
- couchand 11y agoThis 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 rid of any chartjunk is the other big thing. Using four characters of every prompt just for `git:` is not reasonable. And as much as I like the idea of being warned about untracked files, I fear that in most real situations you end up with random scratch files in the same directory. My prompt would always say `7A` at the end, wasting more space (and mental effort!). Good work!
- michaelallen 11y agoThanks! 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/themes/michaeldfallen.zsh-theme) 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/prompt.zsh https://github.com/michaeldfallen/git-radar/blob/master/prom.... Or should I be making these "pieces" like `git:(` and `)` configurable through args / env vars? On the untracked files I personally never leave a file untracked. I either commit it or add it to .gitignore. Though I see how you use git differently, how about a --ignore-untracked to ignore untracked files?
- couchand 11y agoYou 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 http://i.imgur.com/sttMpfQ.png
- WorldWideWayne 11y agoThis is okay, but I wish OS X had something as nice as TortoiseGit.
- Walkman 11y agoIf you like this, I recommend oh-my-zsh [1] or prezto[2], both have themes for things like this. [1]: https://github.com/robbyrussell/oh-my-zsh https://github.com/robbyrussell/oh-my-zsh [2]: https://github.com/sorin-ionescu/prezto https://github.com/sorin-ionescu/prezto
- Shebanator 11y agoI personally use the agnoster theme from oh-my-zsh. With the required powerline-patched font, its very readable and has enough git info to keep me informed without taking up too much space: https://gist.github.com/agnoster/3712874 https://gist.github.com/agnoster/3712874
- toddchambery 11y agoAnybody have a translation for the fish shell prompt?
- pwenzel 11y agoCheck out the "bash-git-prompt" project, which includes this fish prompt: https://github.com/magicmonty/bash-git-prompt/blob/master/gitprompt.fish https://github.com/magicmonty/bash-git-prompt/blob/master/gi...
- JoshTriplett 11y agoI like the appearance of prompts like this, and I've tried them a few times, but I always find myself turning them back off the first time I cd into a large git repository and have to wait a full second or two for the prompt to return. git is fast, but the prompt needs to show up instantly, and git isn't instantaneous on repositories the size of Linux or Chrome.
- anishathalye 11y agoHave you thought about using an asynchronously rendered prompt?
- JoshTriplett 11y agoThat sounds disconcerting and distracting; I don't want my prompt to change while I'm typing a command. If I already have a command prompt, I can type "git status" easily enough. Also, how would that work?
- anishathalye 11y agoIt's not that bad actually - I've been using one since February. Here's a demo (+ code): http://www.anishathalye.com/2015/02/07/an-asynchronous-shell-prompt/ http://www.anishathalye.com/2015/02/07/an-asynchronous-shell...
- JoshTriplett 11y agoAh, I see. Interesting zsh magic, and the right-prompt mechanism makes it more palatable. Two issues, though. First, I use bash. Second, and more importantly, you're using the same temporary file for all shells, so the prompts from different shells (in different working directories) will overwrite each other.
- anishathalye 11y agoYeah, not sure if/how to do this in bash :P Yeah, I thought about using a different temp file per shell, and I did use that for some time, but that got annoying when shells didn't exit gracefully and clean up the temp file. I don't actually care about race conditions (okay, the wrong prompt may be displayed once, big deal), and it doesn't actually happen in real use because of the way timing works out.