From 3f1dddd7dc7fc8ebbfb964d288c4d2317bc6120e Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Thu, 1 Feb 2024 17:57:14 -0600 Subject: feat: add cht.sh integration to tmux --- .local/bin/cht.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 .local/bin/cht.sh (limited to '.local/bin/cht.sh') diff --git a/.local/bin/cht.sh b/.local/bin/cht.sh new file mode 100755 index 0000000..02a5700 --- /dev/null +++ b/.local/bin/cht.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + + +langs=("assembly" "awk" "bash" "basic" "bf" "chapel" "clojure" "coffee" "cpp" "c" "csharp" "d" + "dart" "delphi" "elisp" "elixir" "elm" "erlang" "factor" "forth" "fortran" "fsharp" "git" "go" + "groovy" "haskell" "java" "js" "julia" "kotlin" "latex" "lisp" "lua" "mathematica" "matlab" + "mongo" "nim" "objective" "ocaml" "octave" "perl" "perl6" "php" "psql" "python" "python3" + "r" "racket" "ruby" "rust" "solidity" "scala" "scheme" "psql" "sql" "swift" "tcl" "tcsh" "vb" + "vbnet" "vim" "arduino" "pike" "eiffel" "clean" "dylan" "cmake" "django" "flask") + +selected=$(printf '%s\n' "${langs[@]}" | fzf) +if [ -z $selected ]; then + exit 0 +fi + +echo "Language: $selected" +read -p "Enter Query: " query + +# To differentiate between blank, non-blank, empty, unset +# https://unix.stackexchange.com/a/147362 +case ${query+x$query} in + (x*[![:blank:]]*) + query="/$(echo $query | tr ' ' '+')";; + # curl -s cht.sh/$selected/$query && while [ : ]; do sleep 1; done || echo "failed to search on cht.sh";; + # echo \"curl cht.sh/$selected/$query\" + # curl -s cht.sh/$selected/$query + # while [ : ]; do sleep 1; done;; + (*);; + # keep the variable empty + # curl -s cht.sh/$selected;; +esac + +echo "curl cht.sh/$selected$query:" +echo "" +curl -s cht.sh/$selected$query | less -- cgit v1.2.3-54-g00ecf