From d6b895b7f12bb7a81121f43183329f6049c68f5a Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Mon, 18 Jul 2022 13:57:54 -0400 Subject: [PATCH] Update README.md --- README.md | 58 ++++++++++++++++++++-------------------------- examples/commit.sh | 4 +--- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index baf1a2e..94f527d 100644 --- a/README.md +++ b/README.md @@ -2,38 +2,45 @@ Gum ===

- Gum Image
+ Gum Image +

Latest Release GoDoc Build Status

+Gum helps you write glamorous bash scripts by providing a collection of +beautiful and highly configurable ready-to-use utilities. -Gum is a collection of command-line utilities that make your shell scripts a -little more glamorous. It gives you the power of -[Bubbles](https://github.com/charmbracelet/bubbles) and [Lip -Gloss](https://github.com/charmbracelet/lipgloss) without needing to write any -Go code. +Let's build a `git commit` helper for your dotfiles. + +Running the ./examples/commit.sh script to commit to git ```bash -# Prompt users for input -NAME=$(gum input --placeholder "What is your name?") +# Get the commit type by asking the user to choose an option from the +# conventional commit Specification and store it in $TYPE. +TYPE=$(gum choose "fix" "feat" "docs" "style" "refactor" "test" "chore" "revert") -# Style some text -gum style --foreground 212 --padding "1 4" \ - --border double --border-foreground 57 \ - "Nice to meet you, $NAME." +# Optionally, provide a scope by prompting for input. +SCOPE=$(gum input --placeholder "scope") -# Do some work while spinning -gum spin --title "Taking a nap..." --title.foreground 212 -- sleep 5 +# Wrap the scope in parentheses if non-empty. +[[ -n "$SCOPE" ]] && SCOPE="($SCOPE)" -# Fuzzy find a file or directory -find . -type f | gum filter +# Prompt for commit message summary. +# We pre-populate the value with the type and scope of the commit message in # +case the user changes their mind. +SUMMARY=$(gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change") + +# Prompt for a multi-line description of these changes +DESCRIPTION=$(gum write --placeholder "Details of this change") ``` -The following example is running from a [single bash script](./examples/demo.sh). +Or, a simplified version (one-liner for your dotfiles as a shell aliases): -Shell running the Gum examples/demo.sh script +```bash +git commit -m "$(gum input)" -m "$(gum write)" +``` ## Installation @@ -48,19 +55,6 @@ pacman -S gum # Nix nix-env -iA nixpkgs.gum - -# Debian/Ubuntu -echo 'deb [trusted=yes] https://repo.charm.sh/apt/ /' \ - | sudo tee /etc/apt/sources.list.d/charm.list -sudo apt update && sudo apt install gum - -# Fedora -echo '[charm] -name=Charm -baseurl=https://repo.charm.sh/yum/ -enabled=1 -gpgcheck=0' | sudo tee /etc/yum.repos.d/charm.repo -sudo yum install gum ``` Or download it: @@ -270,8 +264,6 @@ git commit -m "$(gum input --width 50 --placeholder "Summary of changes")" \ -m "$(gum write --width 80 --placeholder "Details of changes")" ``` -Running the ./examples/commit.sh script to commit to git - #### Open files in your `$EDITOR` By default `gum filter` will display a list of all files (searched recursively) diff --git a/examples/commit.sh b/examples/commit.sh index a19de8c..935da6a 100755 --- a/examples/commit.sh +++ b/examples/commit.sh @@ -14,9 +14,7 @@ TYPE=$(gum choose "fix" "feat" "docs" "style" "refactor" "test" "chore" "revert") SCOPE=$(gum input --placeholder "scope") -if [ -n "$SCOPE" ]; then - SCOPE="($SCOPE)" -fi +[[ -n "$SCOPE" ]] && SCOPE="($SCOPE)" git commit \ -m "$(gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change")" \