From 0823dfb1e679d1dd2ae4b5221bf68e3a89d2ae09 Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Sat, 13 Mar 2021 18:34:45 +0300 Subject: [PATCH] Split curl scripts --- README.md | 2 +- deploy.sh | 4 +-- home/.bashrc-bloated | 2 -- home/.config/fish/conf.d/aliases.fish | 1 - home/.config/fish/fish_plugins | 1 - home/.config/zsh/.zshrc | 2 +- home/.config/zsh/aliases.zsh | 2 -- home/.local/bin/cheat | 3 ++ home/.local/bin/crypt | 10 ++++++ home/.local/bin/cryptorate | 7 ++++ home/.local/bin/curlstuff | 13 -------- home/.local/bin/currency | 3 ++ home/.local/bin/dict | 7 ++++ home/.local/bin/imdb | 6 ++++ home/.local/bin/ipinfo | 5 +++ home/.local/bin/lyrics | 16 ++++++++++ home/.local/bin/moon | 3 ++ home/.local/bin/news | 3 ++ home/.local/bin/newton | 46 +++++++++++++++++++++++++++ home/.local/bin/qrgen | 6 ++++ home/.local/bin/urlify | 10 ++++++ home/.local/bin/wttr | 9 ++++++ 22 files changed, 138 insertions(+), 23 deletions(-) create mode 100755 home/.local/bin/cheat create mode 100755 home/.local/bin/crypt create mode 100755 home/.local/bin/cryptorate delete mode 100755 home/.local/bin/curlstuff create mode 100755 home/.local/bin/currency create mode 100755 home/.local/bin/dict create mode 100755 home/.local/bin/imdb create mode 100755 home/.local/bin/ipinfo create mode 100755 home/.local/bin/lyrics create mode 100755 home/.local/bin/moon create mode 100755 home/.local/bin/news create mode 100755 home/.local/bin/newton create mode 100755 home/.local/bin/qrgen create mode 100755 home/.local/bin/urlify create mode 100755 home/.local/bin/wttr diff --git a/README.md b/README.md index c77cdcc..f3eb4c2 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ - **Shell prompt:** [starship](https://starship.rs/) - **Anime/Manga/Wallpaper:** [gallery-dl](https://github.com/mikf/gallery-dl) / [mangadl-bash](https://github.com/Akianonymus/mangadl-bash), [anime-downloader](https://github.com/anime-dl/anime-downloader) + [trackma](https://github.com/z411/trackma) + [adl](https://github.com/RaitaroH/adl) / [anigrab](https://github.com/ngomile/anigrab) - **CLI/TUI for the Internet:** [translate-shell](https://github.com/soimort/translate-shell) / [argos-translate](https://github.com/argosopentech/argos-translate), [ddgr](https://github.com/jarun/ddgr), [howdoi](https://github.com/gleitz/howdoi), [amfora](https://github.com/makeworld-the-better-one/amfora), [cointop](https://github.com/miguelmota/cointop), [newsboat](https://github.com/newsboat/newsboat), [youtube-dl](https://github.com/ytdl-org/youtube-dl) + [ytmdl](https://github.com/deepjyoti30/ytmdl), [github-cli](https://github.com/cli/cli), [pup](https://github.com/ericchiang/pup), [weechat](https://github.com/weechat/weechat), [curl](https://curl.haxx.se) / [wget](https://www.gnu.org/software/wget/wget.html) / [aria2](https://github.com/aria2/aria2), [tremc](https://github.com/tremc/tremc) + [transmission](https://github.com/transmission/transmission) / [rtorrent](https://github.com/rakshasa/rtorrent), [goaccess](https://github.com/allinurl/goaccess) - - **CLI/TUI for other things:** [tt](https://github.com/runrin/tt), [forgit](https://github.com/wfxr/forgit), [borg](https://github.com/borgbackup/borg), [wendy](https://git.z3bra.org/wendy/log.html), [tokei](https://github.com/XAMPPRocky/tokei), [onefetch](https://github.com/o2sh/onefetch), [calcurse](https://github.com/lfos/calcurse), [qalculate](https://github.com/Qalculate/libqalculate), [fzf](https://github.com/junegunn/fzf), [fd](https://github.com/sharkdp/fd), [ripgrep](https://github.com/BurntSushi/ripgrep), [atool](http://www.nongnu.org/atool/), [rsync](https://rsync.samba.org/), [bottom](https://github.com/clementtsang/bottom), [hyperfine](https://github.com/sharkdp/hyperfine), [delta](https://github.com/dandavison/delta), [bat](https://github.com/sharkdp/bat), [glow](https://github.com/charmbracelet/glow) / [mdcat](https://github.com/lunaryorn/mdcat) / [mdr](https://github.com/MichaelMure/mdr), [exa](https://github.com/ogham/exa), [pandoc](https://github.com/jgm/pandoc), [csview](https://github.com/wfxr/csview), [libsixel](https://github.com/saitoha/libsixel), [buku](https://github.com/jarun/buku), [jq](https://github.com/stedolan/jq), [zoxide](https://github.com/ajeetdsouza/zoxide) / [z.lua](https://github.com/skywind3000/z.lua), [xlsx2csv](https://github.com/dilshod/xlsx2csv), sysstat, psmisc, wireless_tools, tree, renameutils + - **CLI/TUI for other things:** [tt](https://github.com/runrin/tt), [forgit](https://github.com/wfxr/forgit), [borg](https://github.com/borgbackup/borg), [wendy](https://git.z3bra.org/wendy/log.html), [tokei](https://github.com/XAMPPRocky/tokei), [onefetch](https://github.com/o2sh/onefetch), [calcurse](https://github.com/lfos/calcurse), [qalculate](https://github.com/Qalculate/libqalculate), [fzf](https://github.com/junegunn/fzf), [fd](https://github.com/sharkdp/fd), [ripgrep](https://github.com/BurntSushi/ripgrep), [atool](http://www.nongnu.org/atool/), [rsync](https://rsync.samba.org/), [bottom](https://github.com/clementtsang/bottom), [hyperfine](https://github.com/sharkdp/hyperfine), [delta](https://github.com/dandavison/delta), [bat](https://github.com/sharkdp/bat), [glow](https://github.com/charmbracelet/glow) / [mdcat](https://github.com/lunaryorn/mdcat) / [mdr](https://github.com/MichaelMure/mdr), [exa](https://github.com/ogham/exa), [pandoc](https://github.com/jgm/pandoc), [csview](https://github.com/wfxr/csview), [libsixel](https://github.com/saitoha/libsixel), [buku](https://github.com/jarun/buku), [jq](https://github.com/stedolan/jq), [zoxide](https://github.com/ajeetdsouza/zoxide) / [z.lua](https://github.com/skywind3000/z.lua), [xlsx2csv](https://github.com/dilshod/xlsx2csv), [qrencode](https://github.com/fukuchi/libqrencode), sysstat, psmisc, wireless_tools, tree, renameutils - **Selfhosted service:** [LibreTranslate](https://github.com/uav4geo/LibreTranslate), [searx](https://github.com/searx/searx), [yacy](https://github.com/yacy/yacy_search_server), [synapse](https://github.com/matrix-org/synapse), [mastodon](https://github.com/tootsuite/mastodon), [gitea](https://gitea.io/) > `Emacs` deserves its own set of dependencies listed, but I'm lazy -> Check my Doom config for details diff --git a/deploy.sh b/deploy.sh index 118f21b..d8482fa 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,12 +1,12 @@ #!/bin/sh -echo "Shell (bash/zsh/fish): " +echo "Shell (bash/zsh/fish): " | tr -d '\n' read -r shell if [ -z "${shell}" ] then exit fi -echo "Display server (wayland/x11): " +echo "Display server (wayland/x11): " | tr -d '\n' read -r server if [ -z "${server}" ] then exit diff --git a/home/.bashrc-bloated b/home/.bashrc-bloated index 32cf7b1..4836d1b 100644 --- a/home/.bashrc-bloated +++ b/home/.bashrc-bloated @@ -384,8 +384,6 @@ alias mv="mv -vi" alias rm="rm -vr" alias mkdir="mkdir -pv" alias no="grep -viP" -alias wttr="curl wttr.in" -alias myip="curl ipinfo.io/geo" # alias latest_pkg="expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort | tail -n 30" alias yarn="yarn --use-yarnrc $XDG_CONFIG_HOME/yarn/config" alias tmux="TERM=screen-256color tmux" diff --git a/home/.config/fish/conf.d/aliases.fish b/home/.config/fish/conf.d/aliases.fish index 08c6ef4..c4b4678 100644 --- a/home/.config/fish/conf.d/aliases.fish +++ b/home/.config/fish/conf.d/aliases.fish @@ -21,7 +21,6 @@ abbr no 'grep -viP' alias yarn='yarn --use-yarnrc $HOME/.config/yarn/config' abbr tmux 'TERM=screen-256color command tmux' alias catc='bat --style plain --color=always' -alias myip='curl ipinfo.io/geo' # colorizing alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' diff --git a/home/.config/fish/fish_plugins b/home/.config/fish/fish_plugins index 5a24c01..85625d4 100644 --- a/home/.config/fish/fish_plugins +++ b/home/.config/fish/fish_plugins @@ -4,6 +4,5 @@ oakninja/MakeMeFish jorgebucaran/bax.fish laughedelic/pisces wfxr/forgit -oh-my-fish/plugin-wttr jorgebucaran/gitio.fish oh-my-fish/plugin-license diff --git a/home/.config/zsh/.zshrc b/home/.config/zsh/.zshrc index 52783a8..adbe8e4 100644 --- a/home/.config/zsh/.zshrc +++ b/home/.config/zsh/.zshrc @@ -155,7 +155,7 @@ zinit light hlissner/zsh-autopair # Git thingy zinit light wfxr/forgit # zinit light kazhala/dotbare -zinit light unixorn/git-extra-commands +# zinit light unixorn/git-extra-commands # Abbreviations zinit light olets/zsh-abbr diff --git a/home/.config/zsh/aliases.zsh b/home/.config/zsh/aliases.zsh index 80f00ec..e7dac42 100644 --- a/home/.config/zsh/aliases.zsh +++ b/home/.config/zsh/aliases.zsh @@ -11,12 +11,10 @@ alias mv="mv -vi" alias rm="rm -vr" alias mkdir="mkdir -pv" alias no="grep -viP" -alias wttr="curl wttr.in" # alias latest_pkg="expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort | tail -n 30" alias yarn="yarn --use-yarnrc $HOME/.config/yarn/config" alias tmux="TERM=screen-256color tmux" alias catc="bat --style plain --color=always" -alias myip="curl ipinfo.io/geo" # colorizing alias grep="grep --color=auto" alias fgrep="fgrep --color=auto" diff --git a/home/.local/bin/cheat b/home/.local/bin/cheat new file mode 100755 index 0000000..0b5ff7a --- /dev/null +++ b/home/.local/bin/cheat @@ -0,0 +1,3 @@ +#!/bin/sh + +curl "https://cheat.sh/$1" diff --git a/home/.local/bin/crypt b/home/.local/bin/crypt new file mode 100755 index 0000000..9eebec7 --- /dev/null +++ b/home/.local/bin/crypt @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ "$1" = "-e" ]; then + openssl enc -aes-256-cbc -salt -a -in "$2" -out "$3" || { echo "File not found"; return 1; } +elif [ "$1" = "-d" ]; then + openssl enc -aes-256-cbc -d -a -in "$2" -out "$3" || { echo "File not found"; return 1; } +else + echo "Wrong 1st argument. Need -d or -e." + return 1 +fi diff --git a/home/.local/bin/cryptorate b/home/.local/bin/cryptorate new file mode 100755 index 0000000..454496a --- /dev/null +++ b/home/.local/bin/cryptorate @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -n "$2" ]; then + curl "$2.rate.sx/$1" +else + curl "rate.sx/$1" +fi diff --git a/home/.local/bin/curlstuff b/home/.local/bin/curlstuff deleted file mode 100755 index 7bd5ee6..0000000 --- a/home/.local/bin/curlstuff +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -case $1 in - --weather) curl wttr.in/$2;; - --moon) curl wttr.in/Moon;; - --qr) curl qrenco.de/$2;; - --cheat) curl https://cht.sh/$2;; - --crypto) curl rate.sx/$2;; - --url) curl -F 'shorten='$2'' https://0x0.st;; - --news) curl getnews.tech/$2;; - --dict) curl dict://dict.org/d:$2;; - *) ;; -esac diff --git a/home/.local/bin/currency b/home/.local/bin/currency new file mode 100755 index 0000000..eb379d1 --- /dev/null +++ b/home/.local/bin/currency @@ -0,0 +1,3 @@ +#!/bin/sh + +curl -s "https://api.exchangeratesapi.io/latest?base=$1" | jq . diff --git a/home/.local/bin/dict b/home/.local/bin/dict new file mode 100755 index 0000000..121a7dd --- /dev/null +++ b/home/.local/bin/dict @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -z "$1" ]; then + aspell dump master | sort | fzf --no-multi | xargs dict +else + curl "dict://dict.org/d:$1" +fi diff --git a/home/.local/bin/imdb b/home/.local/bin/imdb new file mode 100755 index 0000000..69f8c99 --- /dev/null +++ b/home/.local/bin/imdb @@ -0,0 +1,6 @@ +#!/bin/sh + +apiKey=946f500a +movie=$( (echo "$@" | tr " " + ) | sed 's/-d+//g' ) + +curl -s "http://www.omdbapi.com/?t=$movie&apikey=$apiKey" | jq . diff --git a/home/.local/bin/ipinfo b/home/.local/bin/ipinfo new file mode 100755 index 0000000..7f8b7c2 --- /dev/null +++ b/home/.local/bin/ipinfo @@ -0,0 +1,5 @@ +#!/bin/sh + +# $1=geo for verbose look up + +curl "https://ipinfo.io/$1" diff --git a/home/.local/bin/lyrics b/home/.local/bin/lyrics new file mode 100755 index 0000000..08e629d --- /dev/null +++ b/home/.local/bin/lyrics @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "Artist: " | tr -d '\n' +read -r artist +echo "Song: " | tr -d '\n' +read -r song + +# Nice look +echo "======================== + +" + +artist=$(echo "$artist" | sed s/" "/%20/g | sed s/"&"/%26/g | sed s/,/%2C/g | sed s/-/%2D/g) +song=$(echo "$song" | sed s/" "/%20/g | sed s/"&"/%26/g | sed s/,/%2C/g | sed s/-/%2D/g) + +curl -s "https://api.lyrics.ovh/v1/$artist/$song" | jq -r ".lyrics" diff --git a/home/.local/bin/moon b/home/.local/bin/moon new file mode 100755 index 0000000..591ac58 --- /dev/null +++ b/home/.local/bin/moon @@ -0,0 +1,3 @@ +#!/bin/sh + +curl -s "https://wttr.in/Moon$1" diff --git a/home/.local/bin/news b/home/.local/bin/news new file mode 100755 index 0000000..4b8a6b5 --- /dev/null +++ b/home/.local/bin/news @@ -0,0 +1,3 @@ +#!/bin/sh + +curl "getnews.tech/$1" diff --git a/home/.local/bin/newton b/home/.local/bin/newton new file mode 100755 index 0000000..b12b692 --- /dev/null +++ b/home/.local/bin/newton @@ -0,0 +1,46 @@ +#!/bin/sh + +# validate expression +originalEquation=$(echo "$2" | sed "s/\[/\(/g" | sed "s/\]/\)/g") +parsedExpression=$(echo "$2" | sed "s/\[/\(/g" | sed "s/\]/\)/g" | grep -Eo "[0-9 + -- / * ^ . a-z A-Z ~ : ( ) ]*") +if [ "$parsedExpression" != "$originalEquation" ]; then + echo "Error: Expression contains invalid characters" + return 1 +fi + +equation=$(echo "$originalEquation" | sed "s:/:(over):g" | sed "s/~/|/g" | sed "s/-/%2D/g") +operation=$(echo "$1" | tr "[[:upper:]]" "[[:lower:]]") + +curl -s https://newton.now.sh/api/v2/$operation/"$equation" | grep -Eo '"result":"[a-z A-Z 0-9 ( ) \^ / -- + , ]*' | sed s/'"result":"'//g | tr '"' " " + +# Usage: newton [operation] [expression] +# Examples: +# =================================================== +# |Operations Sample Expression Sample Result| +# |---------------------------------------------------| +# |Simplify [[2x^2]+7]*[4x^2] 8 x^4 + 28 x^2 | +# |Factor x^2 + 2x x (x + 2) | +# |Derive x^2+2x 2 x + 2 | +# |Integrate x^2+2x 1/3 x^3 + x^2 +C| +# |Roots/Zeroes x^2+2x 2, 0 | +# |Tangent 2~x^3 12 x + -16 | (Finding tangent line when x=2 for expression x^3) +# |Area 2:4~x^3 60 | (Finding area under curve from 2 to 4 for expression x^3) +# |Cos pi -1 | +# |Sin pi 0 | +# |Tan pi/4 1 | +# |ArcCos 1 0 | +# |ArcSin 0 0 | +# |ArcTan pi arcsin(pi) | +# |Abs -2 2 | +# |Log 2~8 3 | (Log base 2 of eight) +# =================================================== +# Valid Symbols: + # + add + # - subtract + # [ left parenthesis (you must use brackets bash has a bultin for parenthesis) + # ] right parenthesis (you must use brackets bash has a bultin for parenthesis) + # * multiply + # / divide + # ^ power + # : between the range of left and right side (only for area under curve) + # ~ parameter on right side (only for area, tangent line and log) diff --git a/home/.local/bin/qrgen b/home/.local/bin/qrgen new file mode 100755 index 0000000..f06a0e2 --- /dev/null +++ b/home/.local/bin/qrgen @@ -0,0 +1,6 @@ +#!/bin/sh + +# When you don't want to install `qrencode` yourself +input=$(printf '%s ' "$@") +input=$(echo "$input" | sed s/" "/%20/g) +curl "qrenco.de/$input" diff --git a/home/.local/bin/urlify b/home/.local/bin/urlify new file mode 100755 index 0000000..1fdc5ec --- /dev/null +++ b/home/.local/bin/urlify @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ "$1" = "-e" ]; then + curl https://unshorten.me/s/"$2" +elif [ "$1" = "-s" ]; then + curl https://tinyurl.com/api-create.php?url="$2" +else + echo "Wrong arguments" + return 1 +fi diff --git a/home/.local/bin/wttr b/home/.local/bin/wttr new file mode 100755 index 0000000..a2ad092 --- /dev/null +++ b/home/.local/bin/wttr @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "$2" = "-v2" ]; then + curl "https://v2.wttr.in/$1" +elif [ "$2" = "-v3" ]; then + curl "https://v3.wttr.in/$1.sxl" +else + curl "https://wttr.in/$1" +fi