{"id":13400454,"url":"https://github.com/charmbracelet/gum","last_synced_at":"2025-05-12T13:03:07.599Z","repository":{"id":50346019,"uuid":"502193049","full_name":"charmbracelet/gum","owner":"charmbracelet","description":"A tool for glamorous shell scripts 🎀","archived":false,"fork":false,"pushed_at":"2025-05-12T10:14:44.000Z","size":999,"stargazers_count":19631,"open_issues_count":91,"forks_count":382,"subscribers_count":59,"default_branch":"main","last_synced_at":"2025-05-12T11:28:56.530Z","etag":null,"topics":["bash","shell"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charmbracelet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-06-10T22:09:42.000Z","updated_at":"2025-05-12T10:36:47.000Z","dependencies_parsed_at":"2023-12-21T21:25:18.832Z","dependency_job_id":"64d98e6a-7af6-42f2-b218-e49f7580d7cc","html_url":"https://github.com/charmbracelet/gum","commit_stats":{"total_commits":317,"total_committers":40,"mean_commits":7.925,"dds":0.3249211356466877,"last_synced_commit":"8da9620bfd15eef5b55cfec42572a990b952c056"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmbracelet%2Fgum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmbracelet%2Fgum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmbracelet%2Fgum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmbracelet%2Fgum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charmbracelet","download_url":"https://codeload.github.com/charmbracelet/gum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253730420,"owners_count":21954838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","shell"],"created_at":"2024-07-30T19:00:52.221Z","updated_at":"2025-05-12T13:03:07.519Z","avatar_url":"https://github.com/charmbracelet.png","language":"Go","funding_links":[],"categories":["Go","语言资源库","开源类库","Open source library","Development","shell","💻 Development","终端","bash","Tools","CLI Tools with Great Aesthetics","git-polite","Productivity","Tool","Table of Contents","Bash/Shell","\u003ca name=\"Go\"\u003e\u003c/a\u003eGo","TUI Frameworks \u0026 Libraries","Shell (Bash/Zsh/Fish) 🐚","Applications"],"sub_categories":["go","命令行","Command Line","Pretty-Printing","☸️ Kubernetes","网络服务_其他","Go","Dependencies:","TUI Tool","Development Tools"],"readme":"# Gum\n\n\u003cp\u003e\n    \u003ca href=\"https://stuff.charm.sh/gum/nutritional-information.png\" target=\"_blank\"\u003e\u003cimg src=\"https://stuff.charm.sh/gum/gum.png\" alt=\"Gum Image\" width=\"450\" /\u003e\u003c/a\u003e\n    \u003cbr\u003e\u003cbr\u003e\n    \u003ca href=\"https://github.com/charmbracelet/gum/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/charmbracelet/gum.svg\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/charmbracelet/gum?tab=doc\"\u003e\u003cimg src=\"https://godoc.org/github.com/golang/gddo?status.svg\" alt=\"Go Docs\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/charmbracelet/gum/actions\"\u003e\u003cimg src=\"https://github.com/charmbracelet/gum/workflows/build/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nA tool for glamorous shell scripts. Leverage the power of\n[Bubbles](https://github.com/charmbracelet/bubbles) and [Lip\nGloss](https://github.com/charmbracelet/lipgloss) in your scripts and aliases\nwithout writing any Go code!\n\n\u003cimg alt=\"Shell running the ./demo.sh script\" width=\"600\" src=\"https://vhs.charm.sh/vhs-1qY57RrQlXCuydsEgDp68G.gif\"\u003e\n\nThe above example is running from a single shell script ([source](./examples/demo.sh)).\n\n## Tutorial\n\nGum provides highly configurable, ready-to-use utilities to help you write\nuseful shell scripts and dotfiles aliases with just a few lines of code.\nLet's build a simple script to help you write\n[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)\nfor your dotfiles.\n\nAsk for the commit type with gum choose:\n\n```bash\ngum choose \"fix\" \"feat\" \"docs\" \"style\" \"refactor\" \"test\" \"chore\" \"revert\"\n```\n\n\u003e [!NOTE]\n\u003e This command itself will print to stdout which is not all that useful. To make use of the command later on you can save the stdout to a `$VARIABLE` or `file.txt`.\n\nPrompt for the scope of these changes:\n\n```bash\ngum input --placeholder \"scope\"\n```\n\nPrompt for the summary and description of changes:\n\n```bash\ngum input --value \"$TYPE$SCOPE: \" --placeholder \"Summary of this change\"\ngum write --placeholder \"Details of this change\"\n```\n\nConfirm before committing:\n\n```bash\ngum confirm \"Commit changes?\" \u0026\u0026 git commit -m \"$SUMMARY\" -m \"$DESCRIPTION\"\n```\n\nCheck out the [complete example](https://github.com/charmbracelet/gum/blob/main/examples/commit.sh) for combining these commands in a single script.\n\n\u003cimg alt=\"Running the ./examples/commit.sh script to commit to git\" width=\"600\" src=\"https://vhs.charm.sh/vhs-7rRq3LsEuJVwhwr0xf6Er7.gif\"\u003e\n\n## Installation\n\nUse a package manager:\n\n```bash\n# macOS or Linux\nbrew install gum\n\n# Arch Linux (btw)\npacman -S gum\n\n# Nix\nnix-env -iA nixpkgs.gum\n\n# Flox\nflox install gum\n\n# Windows (via WinGet or Scoop)\nwinget install charmbracelet.gum\nscoop install charm-gum\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eDebian/Ubuntu\u003c/summary\u003e\n\n```bash\nsudo mkdir -p /etc/apt/keyrings\ncurl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg\necho \"deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *\" | sudo tee /etc/apt/sources.list.d/charm.list\nsudo apt update \u0026\u0026 sudo apt install gum\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eFedora/RHEL/OpenSuse\u003c/summary\u003e\n\n```bash\necho '[charm]\nname=Charm\nbaseurl=https://repo.charm.sh/yum/\nenabled=1\ngpgcheck=1\ngpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo\nsudo rpm --import https://repo.charm.sh/yum/gpg.key\n\n# yum\nsudo yum install gum\n\n# zypper\nsudo zypper refresh\nsudo zypper install gum\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eFreeBSD\u003c/summary\u003e\n\n```bash\n# packages\nsudo pkg install gum\n\n# ports\ncd /usr/ports/devel/gum \u0026\u0026 sudo make install clean\n```\n\n\u003c/details\u003e\n\nOr download it:\n\n- [Packages][releases] are available in Debian, RPM, and Alpine formats\n- [Binaries][releases] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD\n\nOr just install it with `go`:\n\n```bash\ngo install github.com/charmbracelet/gum@latest\n```\n\n[releases]: https://github.com/charmbracelet/gum/releases\n\n## Commands\n\n- [`choose`](#choose): Choose an option from a list of choices\n- [`confirm`](#confirm): Ask a user to confirm an action\n- [`file`](#file): Pick a file from a folder\n- [`filter`](#filter): Filter items from a list\n- [`format`](#format): Format a string using a template\n- [`input`](#input): Prompt for some input\n- [`join`](#join): Join text vertically or horizontally\n- [`pager`](#pager): Scroll through a file\n- [`spin`](#spin): Display spinner while running a command\n- [`style`](#style): Apply coloring, borders, spacing to text\n- [`table`](#table): Render a table of data\n- [`write`](#write): Prompt for long-form text\n- [`log`](#log): Log messages to output\n\n## Customization\n\nYou can customize `gum` options and styles with `--flags` and `$ENVIRONMENT_VARIABLES`.\nSee `gum \u003ccommand\u003e --help` for a full view of each command's customization and configuration options.\n\nCustomize with `--flags`:\n\n```bash\n\ngum input --cursor.foreground \"#FF0\" \\\n          --prompt.foreground \"#0FF\" \\\n          --placeholder \"What's up?\" \\\n          --prompt \"* \" \\\n          --width 80 \\\n          --value \"Not much, hby?\"\n```\n\nCustomize with `ENVIRONMENT_VARIABLES`:\n\n```bash\nexport GUM_INPUT_CURSOR_FOREGROUND=\"#FF0\"\nexport GUM_INPUT_PROMPT_FOREGROUND=\"#0FF\"\nexport GUM_INPUT_PLACEHOLDER=\"What's up?\"\nexport GUM_INPUT_PROMPT=\"* \"\nexport GUM_INPUT_WIDTH=80\n\n# --flags can override values set with environment\ngum input\n```\n\n\u003cimg alt=\"Gum input displaying most customization options\" width=\"600\" src=\"https://vhs.charm.sh/vhs-5zb9DlQYA70aL9ZpYLTwKv.gif\"\u003e\n\n## Input\n\nPrompt for input with a simple command.\n\n```bash\ngum input \u003e answer.txt\ngum input --password \u003e password.txt\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-1nScrStFI3BMlCp5yrLtyg.gif\" width=\"600\" alt=\"Shell running gum input typing Not much, you?\" /\u003e\n\n## Write\n\nPrompt for some multi-line text (`ctrl+d` to complete text entry).\n\n```bash\ngum write \u003e story.txt\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-7abdKKrUEukgx9aJj8O5GX.gif\" width=\"600\" alt=\"Shell running gum write typing a story\" /\u003e\n\n## Filter\n\nFilter a list of values with fuzzy matching:\n\n```bash\necho Strawberry \u003e\u003e flavors.txt\necho Banana \u003e\u003e flavors.txt\necho Cherry \u003e\u003e flavors.txt\ngum filter \u003c flavors.txt \u003e selection.txt\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-61euOQtKPtQVD7nDpHQhzr.gif\" width=\"600\" alt=\"Shell running gum filter on different bubble gum flavors\" /\u003e\n\nSelect multiple options with the `--limit` flag or `--no-limit` flag. Use `tab` or `ctrl+space` to select, `enter` to confirm.\n\n```bash\ncat flavors.txt | gum filter --limit 2\ncat flavors.txt | gum filter --no-limit\n```\n\n## Choose\n\nChoose an option from a list of choices.\n\n```bash\necho \"Pick a card, any card...\"\nCARD=$(gum choose --height 15 {{A,K,Q,J},{10..2}}\" \"{♠,♥,♣,♦})\necho \"Was your card the $CARD?\"\n```\n\nYou can also select multiple items with the `--limit` or `--no-limit` flag, which determines\nthe maximum of items that can be chosen.\n\n```bash\ncat songs.txt | gum choose --limit 5\ncat foods.txt | gum choose --no-limit --header \"Grocery Shopping\"\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-3zV1LvofA6Cbn5vBu1NHHl.gif\" width=\"600\" alt=\"Shell running gum choose with numbers and gum flavors\" /\u003e\n\n## Confirm\n\nConfirm whether to perform an action. Exits with code `0` (affirmative) or `1`\n(negative) depending on selection.\n\n```bash\ngum confirm \u0026\u0026 rm file.txt || echo \"File not removed\"\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-3xRFvbeQ4lqGerbHY7y3q2.gif\" width=\"600\" alt=\"Shell running gum confirm\" /\u003e\n\n## File\n\nPrompt the user to select a file from the file tree.\n\n```bash\n$EDITOR $(gum file $HOME)\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-2RMRqmnOPneneIgVJJ3mI1.gif\" width=\"600\" alt=\"Shell running gum file\" /\u003e\n\n## Pager\n\nScroll through a long document with line numbers and a fully customizable viewport.\n\n```bash\ngum pager \u003c README.md\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-3iMDpgOLmbYr0jrYEGbk7p.gif\" width=\"600\" alt=\"Shell running gum pager\" /\u003e\n\n## Spin\n\nDisplay a spinner while running a script or command. The spinner will\nautomatically stop after the given command exits.\n\nTo view or pipe the command's output, use the `--show-output` flag.\n\n```bash\ngum spin --spinner dot --title \"Buying Bubble Gum...\" -- sleep 5\n```\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-3YFswCmoY4o3Q7MyzWl6sS.gif\" width=\"600\" alt=\"Shell running gum spin while sleeping for 5 seconds\" /\u003e\n\nAvailable spinner types include: `line`, `dot`, `minidot`, `jump`, `pulse`, `points`, `globe`, `moon`, `monkey`, `meter`, `hamburger`.\n\n## Table\n\nSelect a row from some tabular data.\n\n```bash\ngum table \u003c flavors.csv | cut -d ',' -f 1\n```\n\n\u003c!-- \u003cimg src=\"https://stuff.charm.sh/gum/table.gif\" width=\"600\" alt=\"Shell running gum table\" /\u003e --\u003e\n\n## Style\n\nPretty print any string with any layout with one command.\n\n```bash\ngum style \\\n\t--foreground 212 --border-foreground 212 --border double \\\n\t--align center --width 50 --margin \"1 2\" --padding \"2 4\" \\\n\t'Bubble Gum (1¢)' 'So sweet and so fresh!'\n```\n\n\u003cimg src=\"https://github.com/charmbracelet/gum/assets/42545625/67468acf-b3e0-4e78-bd89-360739eb44fa\" width=\"600\" alt=\"Bubble Gum, So sweet and so fresh!\" /\u003e\n\n## Join\n\nCombine text vertically or horizontally. Use this command with `gum style` to\nbuild layouts and pretty output.\n\nTip: Always wrap the output of `gum style` in quotes to preserve newlines\n(`\\n`) when using it as an argument in the `join` command.\n\n```bash\nI=$(gum style --padding \"1 5\" --border double --border-foreground 212 \"I\")\nLOVE=$(gum style --padding \"1 4\" --border double --border-foreground 57 \"LOVE\")\nBUBBLE=$(gum style --padding \"1 8\" --border double --border-foreground 255 \"Bubble\")\nGUM=$(gum style --padding \"1 5\" --border double --border-foreground 240 \"Gum\")\n\nI_LOVE=$(gum join \"$I\" \"$LOVE\")\nBUBBLE_GUM=$(gum join \"$BUBBLE\" \"$GUM\")\ngum join --align center --vertical \"$I_LOVE\" \"$BUBBLE_GUM\"\n```\n\n\u003cimg src=\"https://github.com/charmbracelet/gum/assets/42545625/68f7a25d-b495-48dd-982a-cee0c8ea5786\" width=\"600\" alt=\"I LOVE Bubble Gum written out in four boxes with double borders around them.\" /\u003e\n\n## Format\n\n`format` processes and formats bodies of text. `gum format` can parse markdown,\ntemplate strings, and named emojis.\n\n```bash\n# Format some markdown\ngum format -- \"# Gum Formats\" \"- Markdown\" \"- Code\" \"- Template\" \"- Emoji\"\necho \"# Gum Formats\\n- Markdown\\n- Code\\n- Template\\n- Emoji\" | gum format\n\n# Syntax highlight some code\ncat main.go | gum format -t code\n\n# Render text any way you want with templates\necho '{{ Bold \"Tasty\" }} {{ Italic \"Bubble\" }} {{ Color \"99\" \"0\" \" Gum \" }}' \\\n    | gum format -t template\n\n# Display your favorite emojis!\necho 'I :heart: Bubble Gum :candy:' | gum format -t emoji\n```\n\nFor more information on template helpers, see the [Termenv\ndocs](https://github.com/muesli/termenv#template-helpers). For a full list of\nnamed emojis see the [GitHub API](https://api.github.com/emojis).\n\n\u003cimg src=\"https://github.com/charmbracelet/gum/assets/42545625/5cfbb0c8-0022-460d-841b-fec37527ca66\" width=\"300\" alt=\"Running gum format for different types of formats\" /\u003e\n\n## Log\n\n`log` logs messages to the terminal at using different levels and styling using\nthe [`charmbracelet/log`](https://github.com/charmbracelet/log) library.\n\n```bash\n# Log some debug information.\ngum log --structured --level debug \"Creating file...\" name file.txt\n# DEBUG Unable to create file. name=temp.txt\n\n# Log some error.\ngum log --structured --level error \"Unable to create file.\" name file.txt\n# ERROR Unable to create file. name=temp.txt\n\n# Include a timestamp.\ngum log --time rfc822 --level error \"Unable to create file.\"\n```\n\nSee the Go [`time` package](https://pkg.go.dev/time#pkg-constants) for acceptable `--time` formats.\n\nSee [`charmbracelet/log`](https://github.com/charmbracelet/log) for more usage.\n\n\u003cimg src=\"https://vhs.charm.sh/vhs-6jupuFM0s2fXiUrBE0I1vU.gif\" width=\"600\" alt=\"Running gum log with debug and error levels\" /\u003e\n\n## Examples\n\nHow to use `gum` in your daily workflows:\n\nSee the [examples](./examples/) directory for more real world use cases.\n\n- Write a commit message:\n\n```bash\ngit commit -m \"$(gum input --width 50 --placeholder \"Summary of changes\")\" \\\n           -m \"$(gum write --width 80 --placeholder \"Details of changes\")\"\n```\n\n- Open files in your `$EDITOR`\n\n```bash\n$EDITOR $(gum filter)\n```\n\n- Connect to a `tmux` session\n\n```bash\nSESSION=$(tmux list-sessions -F \\#S | gum filter --placeholder \"Pick session...\")\ntmux switch-client -t \"$SESSION\" || tmux attach -t \"$SESSION\"\n```\n\n- Pick a commit hash from `git` history\n\n```bash\ngit log --oneline | gum filter | cut -d' ' -f1 # | copy\n```\n\n- Simple [`skate`](https://github.com/charmbracelet/skate) password selector.\n\n```\nskate list -k | gum filter | xargs skate get\n```\n\n- Uninstall packages\n\n```bash\nbrew list | gum choose --no-limit | xargs brew uninstall\n```\n\n- Clean up `git` branches\n\n```bash\ngit branch | cut -c 3- | gum choose --no-limit | xargs git branch -D\n```\n\n- Checkout GitHub pull requests with [`gh`](https://cli.github.com/)\n\n```bash\ngh pr list | cut -f1,2 | gum choose | cut -f1 | xargs gh pr checkout\n```\n\n- Copy command from shell history\n\n```bash\ngum filter \u003c $HISTFILE --height 20\n```\n\n- `sudo` replacement\n\n```bash\nalias please=\"gum input --password | sudo -nS\"\n```\n\n## Feedback\n\nWe’d love to hear your thoughts on this project. Feel free to drop us a note!\n\n- [Twitter](https://twitter.com/charmcli)\n- [The Fediverse](https://mastodon.social/@charmcli)\n- [Discord](https://charm.sh/chat)\n\n## License\n\n[MIT](https://github.com/charmbracelet/gum/raw/main/LICENSE)\n\n---\n\nPart of [Charm](https://charm.sh).\n\n\u003ca href=\"https://charm.sh/\"\u003e\u003cimg alt=\"The Charm logo\" src=\"https://stuff.charm.sh/charm-badge.jpg\" width=\"400\" /\u003e\u003c/a\u003e\n\nCharm热爱开源 • Charm loves open source\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharmbracelet%2Fgum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharmbracelet%2Fgum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharmbracelet%2Fgum/lists"}