From 62c80d76ebff233817f8881d0bd480668b2db9f4 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Tue, 24 Mar 2020 21:21:54 -0400 Subject: [PATCH 1/6] Automate homebrew release flow --- .github/workflows/homebrew.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/homebrew.yml diff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.yml new file mode 100644 index 0000000..23f26ca --- /dev/null +++ b/.github/workflows/homebrew.yml @@ -0,0 +1,17 @@ +name: homebrew + +on: + push: + tags: '*' + +jobs: + homebrew: + name: Bump Homebrew formula + runs-on: ubuntu-latest + steps: + - uses: mislav/bump-homebrew-formula-action@v1 + with: + # A PR will be sent to github.com/Homebrew/homebrew-core to update this formula: + formula-name: cheat + env: + COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }} From 16ade506720127ec06db6b9acc8ed979f14bd0c7 Mon Sep 17 00:00:00 2001 From: raochsinai Date: Fri, 3 Apr 2020 13:01:25 +0800 Subject: [PATCH 2/6] add complete script for zsh. --- scripts/cheat.zsh | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 scripts/cheat.zsh diff --git a/scripts/cheat.zsh b/scripts/cheat.zsh new file mode 100644 index 0000000..5bb71fb --- /dev/null +++ b/scripts/cheat.zsh @@ -0,0 +1,58 @@ +#compdef cheat + +local -a cheats +cheats=() + +_cheat_complete_cheatsheets() +{ + cheats=("${(f)$(cheat -l -t personal | tail -n +2 | cut -d' ' -f1)}") + _describe -t cheats 'cheats' cheats +} + +_cheat_complete_tags() +{ + taglist=("${(f)$(cheat -T)}") + _describe -t taglist 'taglist' taglist +} + +_cheat_complete_paths() +{ + pathlist=("${(f)$(cheat -d | cut -d':' -f1)}") + _describe -t pathlist 'pathlist' pathlist +} + +_cheat() { + + _arguments -C \ + '(--init)--init[Write a default config file to stdout]: :->none' \ + '(-c --colorize)'{-c,--colorize}'[Colorize output]: :->none' \ + '(-d --directories)'{-d,--directories}'[List cheatsheet directories]: :->none' \ + '(-e --edit)'{-e,--edit}'[Edit ]: :->full' \ + '(-l --list)'{-l,--list}'[List cheatsheets]: :->full' \ + '(-p --path)'{-p,--path}'[Return only sheets found on path ]: :->pathlist' \ + '(-r --regex)'{-r,--regex}'[Treat search as a regex]: :->none' \ + '(-s --search)'{-s,--search}'[Search cheatsheets for ]: :->none' \ + '(-t --tag)'{-t,--tag}'[Return only sheets matching ]: :->taglist' \ + '(-T --tags)'{-T,--tags}'[List all tags in use]: :->none' \ + '(-v --version)'{-v,--version}'[Print the version number]: :->none' \ + '(--rm)--rm[Remove (delete) ]: :->full' \ + + case $state in + (none) + ;; + (full) + _cheat_complete_cheatsheets + ;; + (taglist) + _cheat_complete_tags + ;; + (pathlist) + _cheat_complete_paths + ;; + (*) + _cheat_complete_cheatsheets + ;; + esac +} + +_cheat From 8092687956658bb96c2828740a74317882bd890e Mon Sep 17 00:00:00 2001 From: raochsinai Date: Tue, 7 Apr 2020 14:56:34 +0800 Subject: [PATCH 3/6] change taglist and pathlist to local variable. --- scripts/cheat.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/cheat.zsh b/scripts/cheat.zsh index 5bb71fb..3e6d734 100644 --- a/scripts/cheat.zsh +++ b/scripts/cheat.zsh @@ -1,7 +1,6 @@ #compdef cheat -local -a cheats -cheats=() +local cheats taglist pathlist _cheat_complete_cheatsheets() { From bd53768f6728d598ca5e24e1b629206049fb20f0 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 7 Apr 2020 18:41:00 -0400 Subject: [PATCH 4/6] chore(zsh): set execute perm on cheat.zsh Set execute permission on the `zsh` autocompletion script. --- scripts/cheat.zsh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/cheat.zsh diff --git a/scripts/cheat.zsh b/scripts/cheat.zsh old mode 100644 new mode 100755 From c9840c2d6f7016941c83083692a1273411f8ce45 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 7 Apr 2020 18:47:35 -0400 Subject: [PATCH 5/6] docs(autocompletion): update autocompletion docs Update the autocompletion documentation (in `README` and `man` page) to include information about configuring `zsh` autocompletion script. --- README.md | 11 +++++------ doc/cheat.1 | 16 ++++++++++++---- doc/cheat.1.md | 11 ++++++++--- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6aac381..b40146a 100644 --- a/README.md +++ b/README.md @@ -196,14 +196,13 @@ cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}' Advanced Usage -------------- -Shell autocompletion is currently available for the `bash` and `fish` shells. -Copy the relevant [completion script][completions] into the appropriate -directory on your filesystem to enable autocompletion. (This directory will -vary depending on operating system and shell specifics.) +Shell autocompletion is currently available for `bash`, `fish`, and `zsh`. Copy +the relevant [completion script][completions] into the appropriate directory on +your filesystem to enable autocompletion. (This directory will vary depending +on operating system and shell specifics.) Additionally, `cheat` supports enhanced autocompletion via integration with -[fzf][]. (This feature is currently available on bash only.) To enable `fzf` -integration: +[fzf][]. To enable `fzf` integration: 1. Ensure that `fzf` is available on your `$PATH` 2. Set an envvar: `export CHEAT_USE_FZF=true` diff --git a/doc/cheat.1 b/doc/cheat.1 index 41bd437..5b2c932 100644 --- a/doc/cheat.1 +++ b/doc/cheat.1 @@ -175,15 +175,17 @@ For detailed instructions on how to configure cheatpaths, please refer to the comments in conf.yml. .SS Autocompletion .PP -Autocompletion scripts for \f[B]bash\f[]/\f[B]zsh\f[] and \f[B]fish\f[] -are available for download: +Autocompletion scripts for \f[B]bash\f[], \f[B]zsh\f[], and +\f[B]fish\f[] are available for download: .IP \[bu] 2 .IP \[bu] 2 +.IP \[bu] 2 + .PP -The \f[B]bash\f[]/\f[B]zsh\f[] scripts provide optional integration with -\f[B]fzf\f[], if the latter is available on your \f[B]PATH\f[]. +The \f[B]bash\f[] and \f[B]zsh\f[] scripts provide optional integration +with \f[B]fzf\f[], if the latter is available on your \f[B]PATH\f[]. .PP The installation process will vary per system and shell configuration, and thus will not be discussed here. @@ -195,6 +197,12 @@ If \f[B]CHEAT_CONFIG_PATH\f[] is set, all other config paths will be ignored. .RS .RE +.TP +.B \f[B]CHEAT_USE_FZF\f[] +If set, autocompletion scripts will attempt to integrate with +\f[B]fzf\f[]. +.RS +.RE .SH BUGS .PP See GitHub issues: diff --git a/doc/cheat.1.md b/doc/cheat.1.md index 1fa69bc..f587195 100644 --- a/doc/cheat.1.md +++ b/doc/cheat.1.md @@ -137,14 +137,15 @@ comments in conf.yml. Autocompletion -------------- -Autocompletion scripts for **bash**/**zsh** and **fish** are available for +Autocompletion scripts for **bash**, **zsh**, and **fish** are available for download: - - +- -The **bash**/**zsh** scripts provide optional integration with **fzf**, if the -latter is available on your **PATH**. +The **bash** and **zsh** scripts provide optional integration with **fzf**, if +the latter is available on your **PATH**. The installation process will vary per system and shell configuration, and thus will not be discussed here. @@ -158,6 +159,10 @@ ENVIRONMENT : The path at which the config file is available. If **CHEAT_CONFIG_PATH** is set, all other config paths will be ignored. +**CHEAT_USE_FZF** + +: If set, autocompletion scripts will attempt to integrate with **fzf**. + BUGS ==== From e8a0ea0dc360b7db6f30db58a3ebe055d04d2ce6 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 7 Apr 2020 18:50:00 -0400 Subject: [PATCH 6/6] chore(version): bump version to 3.9.0 --- cmd/cheat/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cheat/main.go b/cmd/cheat/main.go index e22b915..13b2f9b 100755 --- a/cmd/cheat/main.go +++ b/cmd/cheat/main.go @@ -17,7 +17,7 @@ import ( "github.com/cheat/cheat/internal/installer" ) -const version = "3.8.0" +const version = "3.9.0" func main() {