diff options
-rwxr-xr-x | git-sonar | 49 |
1 files changed, 15 insertions, 34 deletions
@@ -518,8 +518,7 @@ render_prompt() { ################################################################################ # Original main ################################################################################ - -if [[ -z "$*" ]]; then +usage() { _git="\033[1;30mgit:(\033[0m" _master="\033[0;37mmaster\033[0m" _my_branch="\033[0;37mmy-branch\033[0m" @@ -563,43 +562,25 @@ if [[ -z "$*" ]]; then echo "" echo "usage:" - echo " git-sonar [--zsh|--bash|--fish] [--fetch]" - echo "" - echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" - echo " --zsh # Output prompt using Zsh style color characters" - echo " --bash # Output prompt using Bash style color characters" - echo " --fish # Output prompt using fish style color characters" - echo "" - echo "Bash example:" - echo " export PS1=\"\\W\\\$(git-sonar --bash --fetch) \"" - echo "" - echo " This will show your current directory and the full git-sonar." - echo " As an added benefit, if you are in a repo, it will asynchronously" - echo " run \`git fetch\` every 5 mins, so that you are never out of date." - echo "" - echo "Zsh example:" - echo " export PROMPT=\"%1/%\\\$(git-sonar --zsh --fetch) \"" - echo "" - echo " Same as the Bash but for Zsh." + echo " git-sonar [-h|--help] [-f|--fetch] [--zsh|--bash|--fish]" echo "" - echo "fish example:" - echo " function fish_prompt" - echo " set_color \$fish_color_cwd" - echo " echo -n (prompt_pwd)" - echo " git-sonar --fish -fetch" - echo " set_color normal" - echo " echo -n ' > '" - echo " end" - echo "" - echo " Same as the Bash but for fish." - exit -fi + echo " -h --help # Display this text" + echo " -f --fetch # Periodically fetch your repo asynchronously in the background" + echo " --zsh # (does nothing - for compatibility with git-radar)" + echo " --bash # (does nothing - for compatibility with git-radar)" + echo " --fish # (does nothing - for compatibility with git-radar)" +} -while [[ $# -gt 0 ]];do +while [[ $# -gt 0 ]]; do command="$1" shift - if [[ "$command" == "--fetch" ]]; then + if [[ "$command" == "-h" ]] || [[ "$command" == "--help" ]]; then + usage + exit + fi + + if [[ "$command" == "-f" ]] || [[ "$command" == "--fetch" ]]; then fetch >/dev/null 2>&1 fi done |