mirror of https://github.com/cheat/cheat.git
chore: deletes `fzf.bash`
Deletes `fzf.bash`, which was always intended to be a temporary placeholder anticipating future improvements.
This commit is contained in:
parent
a59c019642
commit
825bd0139d
|
@ -1,9 +1,64 @@
|
||||||
function _cheat_autocomplete {
|
_cheat_cheatpaths()
|
||||||
sheets=$(cheat -l | sed -n '2,$p'|cut -d' ' -f1)
|
{
|
||||||
COMPREPLY=()
|
if [[ -z "${cur// }" ]]; then
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
compgen -W "$(cheat -d | cut -d':' -f1)"
|
||||||
COMPREPLY=(`compgen -W "$sheets" -- $2`)
|
else
|
||||||
fi
|
compgen -W "$(cheat -d | cut -d':' -f1 | grep $cur)"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F _cheat_autocomplete cheat
|
_cheat_cheatsheets()
|
||||||
|
{
|
||||||
|
if [[ "${CHEAT_USE_FZF:-0}" != 0 ]]; then
|
||||||
|
FZF_COMPLETION_TRIGGER='' _fzf_complete "--no-multi" "$@" < <(cheat -l | tail -n +2 | cut -d' ' -f1)
|
||||||
|
else
|
||||||
|
COMPREPLY=( $(compgen -W "$(cheat -l $cur | tail -n +2 | cut -d' ' -f1)") )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_cheat_tags()
|
||||||
|
{
|
||||||
|
if [[ -z "${cur// }" ]]; then
|
||||||
|
compgen -W "$(cheat -T)"
|
||||||
|
else
|
||||||
|
compgen -W "$(cheat -T | grep $cur)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_cheat()
|
||||||
|
{
|
||||||
|
local cur prev words cword split
|
||||||
|
_init_completion -s || return
|
||||||
|
|
||||||
|
case $prev in
|
||||||
|
--edit|-e)
|
||||||
|
_cheat_cheatsheets
|
||||||
|
;;
|
||||||
|
--path|-p)
|
||||||
|
COMPREPLY=( $(_cheat_cheatpaths) )
|
||||||
|
;;
|
||||||
|
--rm)
|
||||||
|
_cheat_cheatsheets
|
||||||
|
;;
|
||||||
|
--tags|-t)
|
||||||
|
COMPREPLY=( $(_cheat_tags) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$split && return
|
||||||
|
|
||||||
|
if [[ ! "$cur" =~ ^-.* ]]; then
|
||||||
|
_cheat_cheatsheets
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $cur == -* ]]; then
|
||||||
|
COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
|
||||||
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
} &&
|
||||||
|
complete -F _cheat cheat
|
||||||
|
|
||||||
|
# ex: filetype=sh
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This function enables you to choose a cheatsheet to view by selecting output
|
|
||||||
# from `cheat -l`. `source` it in your shell to enable it. (Consider renaming
|
|
||||||
# or aliasing it to something convenient.)
|
|
||||||
|
|
||||||
# Arguments passed to this function (like --color) will be passed to the second
|
|
||||||
# invokation of `cheat`.
|
|
||||||
function cheat-fzf {
|
|
||||||
eval `cheat -l | tail -n +2 | fzf | awk -v vars="$*" '{ print "cheat " $1 " -t " $3, vars }'`
|
|
||||||
}
|
|
Loading…
Reference in New Issue