在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:michaeldfallen/git-radar开源软件地址:https://github.com/michaeldfallen/git-radar开源编程语言:Shell 99.2%开源软件介绍:Git RadarA heads up display for git. Git-radar is a tool you can add to your prompt to provide at-a-glance information on your git repo. It's a labour of love I've been dogfooding for the last few years. Maybe it can help you too. Table of Contents InstallationInstall from brew:
Manually:
Then run UsageTo use git-radar you need to add it to your prompt. This is done in different ways depending on your shell. Bash Add to your export PS1="$PS1\$(git-radar --bash --fetch)" (note: the Zsh Add to your export PROMPT="$PROMPT\$(git-radar --zsh --fetch) " (note: the Fish Add to your function fish_prompt
set_color $fish_color_cwd
echo -n (prompt_pwd)
echo -n (git-radar --fish --fetch)
set_color normal
echo -n ' > '
end FeaturesFiles statusThe prompt lists the file changes and whether they are staged, unstaged or untracked. Each symbol represents a different change to a file. These are based on what git considers has happened to the file.
The color tells you what stage the change is at.
The use of feature is controlled by the Local commits statusThe prompt will show you the difference in commits between your branch and the
remote your branch is tracking. The examples below assume you are checked out on
The use of feature is controlled by the Remote commits statusThe prompt will also show the difference between your branch on origin and what
is on This is the difference between the commits you've pushed up and The use of feature is controlled by the Stash statusThe prompt will show you whether and how many stashes you have stored.
If you don't rely on this status, you can always hide this part of the prompt by customising your prompt (Optional) Auto-fetch reposEnsuring your refs are up to date I found can be a pain. To streamline this
git-radar can be configured to auto-fetch your repo. When the This will only occur when the prompt is rendered and it will only occur on the repo you are currently in. To use this feature, when setting your prompt, call git-radar with Bash export PS1="$PS1\$(git-radar --bash --fetch)" (note: the Zsh export PROMPT="$PROMPT\$(git-radar --zsh --fetch) " (note: the You may also choose to fetch at a customized interval of time. To do so, add this to your .bashrc, .zshrc: export GIT_RADAR_FETCH_TIME=<seconds> For example, to fetch every 30 seconds (instead of the default 5 minutes): export GIT_RADAR_FETCH_TIME=30 You can also do this in the gitradarrc file: GIT_RADAR_FETCH_TIME=30 Customise your promptGit Radar is highly customisable using a prompt format string. The 4 features above: remote commits, local commits, branch and file changes; are controlled by the prompt format string.
You can create any prompt shape you prefer by exporting Examples
Prefixing and Suffixing the featuresOften you will want certain parts of the prompt to only appear when there is
content to render. For example, when in a repo you want To do this the control strings support prefixes and suffixes. Prefixes and
Suffixes are separated from the feature name by Format: In a repo: Outside a repo: The default prompt format uses this to add spaces only if the feature would render. In that way the prompt always looks well spaced out no matter how many features are rendering. SupportEnsuring prompt executionWhen setting your prompt variable, 1. Use export PROMPT=$'$(git-radar --zsh)'
export PS1=$'$(git-radar --bash)' 2. Use export PROMPT="\$(git-radar --zsh)"
export PS1="\$(git-radar --bash)" Configuring coloursYou can configure the colour scheme in two ways: export Environment Variables or use an rc file. Exporting Environment VariablesTo configure the prompt this way just add to your Example: Change the branch colour in Zsh In export GIT_RADAR_COLOR_BRANCH='$fg[yellow]' Example: Change the branch colour in Bash In export GIT_RADAR_COLOR_BRANCH='\\033[0;33m' Setting an RC fileGit radar supports multiple rc files. One of these will be sourced when the prompt renders. Example: Change the branch colour in Zsh In GIT_RADAR_COLOR_BRANCH='$fg[yellow]' Basic RC file Create a file at Shell specific RC file If you use both Bash and Zsh you can set RC files that are specific for those shells. For Bash: Create a file at For Zsh: Create a file at Bash Colour CodesBash colour codes make use of the colours your terminal app claims to be Note the "Bright" colours can be shown as bold instead, it depends on your terminal. By default, for example, the Mac OSX Terminal.app uses the "Bright" colours to provide 8 new lighter colours but some terminals only support 8 and will show the text as bold instead.
Note the Reset will set back to what your terminal claims as standard text and background. Zsh Colour CodesZsh also provides a way to access the colours that your terminal claims as Note the "Bright" colours can be shown as bold instead, it depends on your terminal. By default, for example, the Mac OSX Terminal.app uses the "Bright" colours to provide 8 new lighter colours but some terminals only support 8 and will show the text as bold instead.
Configuration valuesAll these values should be set using a the correct colour code for your terminal. You should also choose the colour code based on what shell you are using. There is a way to support colouring multiple shells using rc files. Colouring the Branch partGIT_RADAR_COLOR_BRANCH='[colour code]'
The colour to use for the Branch or git reference. It is unset by
Colouring the local commits statusGIT_RADAR_COLOR_LOCAL_AHEAD='[colour code]'
The colour to use for the arrow that indicates how many commits you have to push up. It is unset by GIT_RADAR_COLOR_LOCAL_BEHIND='[colour code]'
The colour to use for the arrow that indicates how many commits you have to pull down. It is unset by GIT_RADAR_COLOR_LOCAL_DIVERGED='[colour code]'
The colour to use for the arrow that indicates how many commits your branch has diverged by. It is unset by Colouring the remote commits statusGIT_RADAR_COLOR_REMOTE_AHEAD='[colour code]'
The colour to use for the arrow that indicates how many commits your branch has to merge on to master. It is unset by GIT_RADAR_COLOR_REMOTE_BEHIND='[colour code]'
The colour to use for the arrow that indicates how many commits your branch is behind master. It is unset by GIT_RADAR_COLOR_REMOTE_DIVERGED='[colour code]'
The colour to use for the arrow that indicates how many commits your branch has diverged from master. It is unset by GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM='[colour code]'
The colour to use for the lightning bolt which indicates that your branch is not tracking an upstream branch. It is unset by Colouring the file changes statusGIT_RADAR_COLOR_CHANGES_STAGED='[colour code]'
The colour to use for the letters that indicate changes that have been staged to commit. It is unset by GIT_RADAR_COLOR_CHANGES_UNSTAGED='[colour code]'
The colour to use for the letters that indicate changes that have not yet been staged to commit. It is unset by GIT_RADAR_COLOR_CHANGES_CONFLICTED='[colour code]'
The colour to use for the letters that indicate changes that have conflicts that need resolved. It is unset by GIT_RADAR_COLOR_CHANGES_UNTRACKED='[colour code]'
The colour to use for the letters that indicate files that are currently not tracked by git. It is unset by Colouring the stash statusGIT_RADAR_COLOR_STASH='[colour code]'
The colour to use for the lines that indicates how many stashes you have stored. It is unset by LicenseGit Radar is licensed under the MIT license. See LICENSE for the full license text. Links
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论