summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2024-02-01 17:57:14 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2024-02-01 17:57:14 -0600
commit3f1dddd7dc7fc8ebbfb964d288c4d2317bc6120e (patch)
treea90ba24e548a8ec84c02165c65398b15bae684e5 /.local
parent7dd853749eff174bf9acb3785095e55ce545aaec (diff)
feat: add cht.sh integration to tmux
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/cht.sh35
1 files changed, 35 insertions, 0 deletions
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