1
- Gum
2
- ===
1
+ # Gum
3
2
4
3
<p >
5
4
<a href="https://stuff.charm.sh/gum/nutritional-information.png" target="_blank"><img src="https://stuff.charm.sh/gum/gum.png" alt="Gum Image" width="450" /></a>
@@ -22,10 +21,12 @@ The above example is running from a single shell script ([source](./examples/dem
22
21
23
22
Gum provides highly configurable, ready-to-use utilities to help you write
24
23
useful shell scripts and dotfiles aliases with just a few lines of code.
25
- Let's build a simple script to help you write [ Conventional Commits] ( https://www.conventionalcommits.org/en/v1.0.0/#summary )
24
+ Let's build a simple script to help you write
25
+ [ Conventional Commits] ( https://www.conventionalcommits.org/en/v1.0.0/#summary )
26
26
for your dotfiles.
27
27
28
28
Ask for the commit type with gum choose:
29
+
29
30
``` bash
30
31
gum choose " fix" " feat" " docs" " style" " refactor" " test" " chore" " revert"
31
32
```
@@ -34,17 +35,20 @@ gum choose "fix" "feat" "docs" "style" "refactor" "test" "chore" "revert"
34
35
> 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 ` .
35
36
36
37
Prompt for the scope of these changes:
38
+
37
39
``` bash
38
40
gum input --placeholder " scope"
39
41
```
40
42
41
43
Prompt for the summary and description of changes:
44
+
42
45
``` bash
43
46
gum input --value " $TYPE$SCOPE : " --placeholder " Summary of this change"
44
47
gum write --placeholder " Details of this change"
45
48
```
46
49
47
50
Confirm before committing:
51
+
48
52
``` bash
49
53
gum confirm " Commit changes?" && git commit -m " $SUMMARY " -m " $DESCRIPTION "
50
54
```
@@ -84,10 +88,11 @@ curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/ke
84
88
echo " deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
85
89
sudo apt update && sudo apt install gum
86
90
```
91
+
87
92
</details >
88
93
89
94
<details >
90
- <summary >Fedora/RHEL</summary >
95
+ <summary >Fedora/RHEL/OpenSuse </summary >
91
96
92
97
``` bash
93
98
echo ' [charm]
@@ -96,14 +101,22 @@ baseurl=https://repo.charm.sh/yum/
96
101
enabled=1
97
102
gpgcheck=1
98
103
gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
104
+ sudo rpm --import https://repo.charm.sh/yum/gpg.key
105
+
106
+ # yum
99
107
sudo yum install gum
108
+
109
+ # zypper
110
+ sudo zypper refresh
111
+ sudo zypper install gum
100
112
```
113
+
101
114
</details >
102
115
103
116
Or download it:
104
117
105
- * [ Packages] [ releases ] are available in Debian, RPM, and Alpine formats
106
- * [ Binaries] [ releases ] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD
118
+ - [ Packages] [ releases ] are available in Debian, RPM, and Alpine formats
119
+ - [ Binaries] [ releases ] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD
107
120
108
121
Or just install it with ` go ` :
109
122
@@ -115,27 +128,27 @@ go install github.com/charmbracelet/gum@latest
115
128
116
129
## Commands
117
130
118
- * [ ` choose ` ] ( #choose ) : Choose an option from a list of choices
119
- * [ ` confirm ` ] ( #confirm ) : Ask a user to confirm an action
120
- * [ ` file ` ] ( #file ) : Pick a file from a folder
121
- * [ ` filter ` ] ( #filter ) : Filter items from a list
122
- * [ ` format ` ] ( #format ) : Format a string using a template
123
- * [ ` input ` ] ( #input ) : Prompt for some input
124
- * [ ` join ` ] ( #join ) : Join text vertically or horizontally
125
- * [ ` pager ` ] ( #pager ) : Scroll through a file
126
- * [ ` spin ` ] ( #spin ) : Display spinner while running a command
127
- * [ ` style ` ] ( #style ) : Apply coloring, borders, spacing to text
128
- * [ ` table ` ] ( #table ) : Render a table of data
129
- * [ ` write ` ] ( #write ) : Prompt for long-form text
130
- * [ ` log ` ] ( #log ) : Log messages to output
131
-
131
+ - [ ` choose ` ] ( #choose ) : Choose an option from a list of choices
132
+ - [ ` confirm ` ] ( #confirm ) : Ask a user to confirm an action
133
+ - [ ` file ` ] ( #file ) : Pick a file from a folder
134
+ - [ ` filter ` ] ( #filter ) : Filter items from a list
135
+ - [ ` format ` ] ( #format ) : Format a string using a template
136
+ - [ ` input ` ] ( #input ) : Prompt for some input
137
+ - [ ` join ` ] ( #join ) : Join text vertically or horizontally
138
+ - [ ` pager ` ] ( #pager ) : Scroll through a file
139
+ - [ ` spin ` ] ( #spin ) : Display spinner while running a command
140
+ - [ ` style ` ] ( #style ) : Apply coloring, borders, spacing to text
141
+ - [ ` table ` ] ( #table ) : Render a table of data
142
+ - [ ` write ` ] ( #write ) : Prompt for long-form text
143
+ - [ ` log ` ] ( #log ) : Log messages to output
132
144
133
145
## Customization
134
146
135
147
You can customize ` gum ` options and styles with ` --flags ` and ` $ENVIRONMENT_VARIABLES ` .
136
148
See ` gum <command> --help ` for a full view of each command's customization and configuration options.
137
149
138
150
Customize with ` --flags ` :
151
+
139
152
``` bash
140
153
141
154
gum input --cursor.foreground " #FF0" \
@@ -369,63 +382,63 @@ How to use `gum` in your daily workflows:
369
382
370
383
See the [ examples] ( ./examples/ ) directory for more real world use cases.
371
384
372
- * Write a commit message:
385
+ - Write a commit message:
373
386
374
387
``` bash
375
388
git commit -m " $( gum input --width 50 --placeholder " Summary of changes" ) " \
376
389
-m " $( gum write --width 80 --placeholder " Details of changes" ) "
377
390
```
378
391
379
- * Open files in your ` $EDITOR `
392
+ - Open files in your ` $EDITOR `
380
393
381
394
``` bash
382
395
$EDITOR $( gum filter)
383
396
```
384
397
385
- * Connect to a ` tmux ` session
398
+ - Connect to a ` tmux ` session
386
399
387
400
``` bash
388
401
SESSION=$( tmux list-sessions -F \# S | gum filter --placeholder " Pick session..." )
389
402
tmux switch-client -t $SESSION || tmux attach -t $SESSION
390
403
```
391
404
392
- * Pick a commit hash from ` git ` history
405
+ - Pick a commit hash from ` git ` history
393
406
394
407
``` bash
395
408
git log --oneline | gum filter | cut -d' ' -f1 # | copy
396
409
```
397
410
398
- * Simple [ ` skate ` ] ( https://github.com/charmbracelet/skate ) password selector.
411
+ - Simple [ ` skate ` ] ( https://github.com/charmbracelet/skate ) password selector.
399
412
400
413
```
401
414
skate list -k | gum filter | xargs skate get
402
415
```
403
416
404
- * Uninstall packages
417
+ - Uninstall packages
405
418
406
419
``` bash
407
420
brew list | gum choose --no-limit | xargs brew uninstall
408
421
```
409
422
410
- * Clean up ` git ` branches
423
+ - Clean up ` git ` branches
411
424
412
425
``` bash
413
426
git branch | cut -c 3- | gum choose --no-limit | xargs git branch -D
414
427
```
415
428
416
- * Checkout GitHub pull requests with [ ` gh ` ] ( https://cli.github.com/ )
429
+ - Checkout GitHub pull requests with [ ` gh ` ] ( https://cli.github.com/ )
417
430
418
431
``` bash
419
432
gh pr list | cut -f1,2 | gum choose | cut -f1 | xargs gh pr checkout
420
433
```
421
434
422
- * Copy command from shell history
435
+ - Copy command from shell history
423
436
424
437
``` bash
425
438
gum filter < $HISTFILE --height 20
426
439
```
427
440
428
- * ` sudo ` replacement
441
+ - ` sudo ` replacement
429
442
430
443
``` bash
431
444
alias please=" gum input --password | sudo -nS"
@@ -435,15 +448,15 @@ alias please="gum input --password | sudo -nS"
435
448
436
449
We’d love to hear your thoughts on this project. Feel free to drop us a note!
437
450
438
- * [ Twitter] ( https://twitter.com/charmcli )
439
- * [ The Fediverse] ( https://mastodon.social/@charmcli )
440
- * [ Discord] ( https://charm.sh/chat )
451
+ - [ Twitter] ( https://twitter.com/charmcli )
452
+ - [ The Fediverse] ( https://mastodon.social/@charmcli )
453
+ - [ Discord] ( https://charm.sh/chat )
441
454
442
455
## License
443
456
444
457
[ MIT] ( https://github.com/charmbracelet/gum/raw/main/LICENSE )
445
458
446
- ***
459
+ ---
447
460
448
461
Part of [ Charm] ( https://charm.sh ) .
449
462
0 commit comments