Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need documentation for using CHEAT_USE_FZF=true #594

Open
ipstone opened this issue Oct 5, 2020 · 2 comments
Open

Need documentation for using CHEAT_USE_FZF=true #594

ipstone opened this issue Oct 5, 2020 · 2 comments

Comments

@ipstone
Copy link

ipstone commented Oct 5, 2020

Is your feature request related to a problem? Please describe.
I am trying using fzf with cheat for autocompletion. Currently bash autocompletion is working (after setting cheat.bash script in the correct path). But I have no clue how to trigger the fzf for completion. ( I looked at the code, but somehow fzf isn't triggered)

Describe the solution you'd like
it would be nice to have clear note in documentation how fzf will be triggered (such as pressing a tab, or expand using ctrl-t (?), or such as using ** to expand when tab is pressed? )

Describe alternatives you've considered
This might not be needed -as usually the cheatsheets for selection isn't a lot; I currently often use cheat -l | grep to get the sheets I need, but it would be nice to have the function built in. More ideally, would allow a tmux pane to show/preview the cheatsheet as fzf is being used to select the cheatsheet.

Additional context
Thanks!

@mohkale
Copy link

mohkale commented May 1, 2021

I'm usng this atm, it works pretty well for me.

function fzcheat() {
  local fzf_args=( -d ':' --ansi --with-nth '2..'
                   --bind 'ctrl-y:execute-silent(echo {1} | clip)'
                   --bind 'alt-e:execute(cheat -e {1})'
                   --bind 'ctrl-m:execute:cheat -c {1} | $PAGER'
                   --history "${XDG_DATA_HOME:-$HOME/.locale/share}"/fzf/history/fzf_cheat )
  [ -z "$*" ] || fzf_args+=( -q "$*" )

  cheat -l |
    awk -v c_tag_l=$'\e[1m' \
        -v c_tag_r=$'\e[0m' \
        -e 'NR == 1 { next }' \
        -e '{
  tags=""
  for (i=3; i <= NF; i++) {
    tags = $i FS
  }
  sub(FS "$", "", tags)
  printf("%s:%s%s\n", $1, $1, tags ? (c_tag_l " [" tags "] " c_tag_r) : "")
}' |
    fzf "${fzf_args[@]}"
}

@KingJulianS
Copy link

KingJulianS commented Aug 26, 2022

@ipstone have you found out how it works already ?
if so, can you please share the steps with me as well pls sir.
I am a complete newb at this and don't even know what is meant by “right directory” ..

This is the best I could do for now on my side :
cheat -l | awk '{print $1}' | fzf | xargs -I{} cheat {}

so did an alias in bashrc
alias fch='cheat -l | awk \047{print$1}\047 | fzf | xargs -I{} cheat {}'

pls let me know if there's a beter way instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants