Skip to content

Commit

Permalink
Add cht.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
ClouddJR committed Oct 7, 2023
1 parent 0ba9021 commit 6b95fd1
Show file tree
Hide file tree
Showing 4 changed files with 824 additions and 0 deletions.
4 changes: 4 additions & 0 deletions shell/.functions
Expand Up @@ -15,6 +15,10 @@ function ql() {
quick-look "$1"
}

function c() {
$HOME/.dotfiles/shell/scripts/cht.sh "$@" | less
}

# 1. Search for text in files using ripgrep
# 2. Interactively narrow down the list using fzf
# 3. Open the file in nvim
Expand Down
3 changes: 3 additions & 0 deletions shell/.zshrc
Expand Up @@ -5,6 +5,9 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# Path to custom completions
fpath=($HOME/.dotfiles/shell/completions/ $fpath)

# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"

Expand Down
21 changes: 21 additions & 0 deletions shell/completions/_cht
@@ -0,0 +1,21 @@
#compdef c

__CHTSH_LANGS=($(curl -s cheat.sh/:list))
_arguments -C \
'--help[show this help message and exit]: :->noargs' \
'--shell[enter shell repl]: :->noargs' \
'1:Cheat Sheet:->lang' \
'*::: :->noargs' && return 0

if [[ CURRENT -ge 1 ]]; then
case $state in
noargs)
_message "nothing to complete";;
lang)
compadd -X "Cheat Sheets" ${__CHTSH_LANGS[@]};;
*)
_message "Unknown state, error in autocomplete";;
esac

return
fi

0 comments on commit 6b95fd1

Please sign in to comment.