linux-config/files/dotfiles/shellconfig/cheat.sh
2022-01-13 19:47:24 +02:00

19 lines
783 B
Bash
Executable file

#!/bin/bash
########################################################
# DO NOT EDIT - WILL BE DISCARDED IN NEXT PLAYBOOK RUN #
########################################################
# Get docs fast
selected=`cat ~/.shellconfig/cheat/topics | fzf --header="🏳️ Select a Topic: " --reverse`
if [[ -z $selected ]]; then
exit 0
fi
read -p "What you want to know?: " query
query=`echo $query | tr ' ' '+'`
if [[ $selected == "TLDR" ]]; then
tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "tldr ${query} | bat --paging=always --file-name='${selected} | Query: ${query}'"
else
tmux neww -n "[🏳️ Cheat: ${selected}/${query}]" bash -c "curl -s https://cht.sh/$selected/$query | bat --paging=always --file-name='Topic: ${selected} | Query: ${query}'"
fi