Kevin Mok
4 years ago
21 changed files with 2017 additions and 106 deletions
-
103aliases/key_aliases.tmpl
-
17aliases/key_dirs.tmpl
-
6aliases/key_files.tmpl
-
4dot_Xmodmap
-
1654dot_config/fish/completions/kubectl.fish
-
21dot_config/fish/config.fish.tmpl
-
3dot_config/fish/functions/cad-to-us.fish
-
3dot_config/fish/functions/libreoffice-silent.fish
-
3dot_config/fish/functions/reminder.fish
-
3dot_config/fish/functions/scan-history.fish
-
1dot_config/fish/functions/us-to-cad.fish
-
37dot_config/i3/config.tmpl
-
60dot_config/i3blocks/i3blocks-secondary.conf.tmpl
-
80dot_config/i3blocks/i3blocks.conf.tmpl
-
5dot_config/i3blocks/scripts/executable_ticker
-
3dot_config/i3blocks/scripts/executable_volume
-
3dot_config/i3blocks/scripts/executable_wifi
-
6dot_taskrc
-
11dot_vimrc.tmpl
-
3scripts/executable_spotify-clean
-
97scripts/executable_ticker
1654
dot_config/fish/completions/kubectl.fish
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,3 @@ |
|||
function cad-to-us |
|||
qalc "$argv[1]CAD to \$" |
|||
end |
@ -0,0 +1,3 @@ |
|||
function libreoffice-silent |
|||
libreoffice $argv[1] & |
|||
end |
@ -0,0 +1,3 @@ |
|||
function reminder |
|||
termdown $argv[2] && notify-send $argv[1] |
|||
end |
@ -1,3 +1,4 @@ |
|||
function us-to-cad |
|||
# qalc -e "$argv[1]\$ to CAD" |
|||
qalc "$argv[1]\$ to CAD" |
|||
end |
@ -0,0 +1,5 @@ |
|||
#!/bin/bash |
|||
|
|||
. "/home/kevin/.cache/wal/colors.sh" |
|||
ticker=$(~/scripts/ticker $TICKER) |
|||
printf "%s\n\n%s\n" "$ticker" "$color7" |
@ -0,0 +1,3 @@ |
|||
#!/bin/dash |
|||
|
|||
sqlite3 ~/.cache/spotify/mercury.db 'VACUUM;' && spotify |
@ -0,0 +1,97 @@ |
|||
#!/usr/bin/env bash |
|||
set -e |
|||
|
|||
LANG=C |
|||
LC_NUMERIC=C |
|||
|
|||
SYMBOLS=("$@") |
|||
|
|||
if ! $(type jq > /dev/null 2>&1); then |
|||
echo "'jq' is not in the PATH. (See: https://stedolan.github.io/jq/)" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ -z "$SYMBOLS" ]; then |
|||
echo "Usage: ./ticker.sh AAPL MSFT GOOG BTC-USD" |
|||
exit |
|||
fi |
|||
|
|||
FIELDS=(symbol marketState regularMarketPrice regularMarketChange regularMarketChangePercent \ |
|||
preMarketPrice preMarketChange preMarketChangePercent postMarketPrice postMarketChange postMarketChangePercent) |
|||
API_ENDPOINT="https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US®ion=US&corsDomain=finance.yahoo.com" |
|||
|
|||
if [ -z "$NO_COLOR" ]; then |
|||
: "${COLOR_BOLD:=\e[1;37m}" |
|||
: "${COLOR_GREEN:=\e[32m}" |
|||
: "${COLOR_RED:=\e[31m}" |
|||
: "${COLOR_RESET:=\e[00m}" |
|||
fi |
|||
|
|||
symbols=$(IFS=,; echo "${SYMBOLS[*]}") |
|||
fields=$(IFS=,; echo "${FIELDS[*]}") |
|||
|
|||
results=$(curl --silent "$API_ENDPOINT&fields=$fields&symbols=$symbols" \ |
|||
| jq '.quoteResponse .result') |
|||
|
|||
query () { |
|||
echo $results | jq -r ".[] | select(.symbol == \"$1\") | .$2" |
|||
} |
|||
|
|||
for symbol in $(IFS=' '; echo "${SYMBOLS[*]}" | tr '[:lower:]' '[:upper:]'); do |
|||
marketState="$(query $symbol 'marketState')" |
|||
|
|||
if [ -z $marketState ]; then |
|||
printf 'No results for symbol "%s"\n' $symbol |
|||
continue |
|||
fi |
|||
|
|||
preMarketChange="$(query $symbol 'preMarketChange')" |
|||
postMarketChange="$(query $symbol 'postMarketChange')" |
|||
|
|||
if [ $marketState == "PRE" ] \ |
|||
&& [ $preMarketChange != "0" ] \ |
|||
&& [ $preMarketChange != "null" ]; then |
|||
nonRegularMarketSign='*' |
|||
price=$(query $symbol 'preMarketPrice') |
|||
diff=$preMarketChange |
|||
percent=$(query $symbol 'preMarketChangePercent') |
|||
elif [ $marketState != "REGULAR" ] \ |
|||
&& [ $postMarketChange != "0" ] \ |
|||
&& [ $postMarketChange != "null" ]; then |
|||
nonRegularMarketSign='*' |
|||
price=$(query $symbol 'postMarketPrice') |
|||
diff=$postMarketChange |
|||
percent=$(query $symbol 'postMarketChangePercent') |
|||
else |
|||
nonRegularMarketSign='' |
|||
price=$(query $symbol 'regularMarketPrice') |
|||
diff=$(query $symbol 'regularMarketChange') |
|||
percent=$(query $symbol 'regularMarketChangePercent') |
|||
fi |
|||
|
|||
if [ "$diff" == "0" ]; then |
|||
color= |
|||
elif ( echo "$diff" | grep -q ^- ); then |
|||
color=$COLOR_RED |
|||
else |
|||
color=$COLOR_GREEN |
|||
fi |
|||
|
|||
if [ "$price" != "null" ]; then |
|||
# printf "%-10s$COLOR_BOLD%8.2f$COLOR_RESET" $symbol $price |
|||
# printf "$color%10.2f%12s$COLOR_RESET" $diff $(printf "(%.2f%%)" $percent) |
|||
# printf " %s\n" "$nonRegularMarketSign" |
|||
# echo \$$price |
|||
# echo $price |
|||
hour=$(date +"%H") |
|||
if [[ "$symbol" == "USDCAD=X" ]]; then |
|||
printf "%0.4f\n" $price |
|||
elif [[ "$symbol" == "ADA"* ]]; then |
|||
printf "%0.3f\n" $price |
|||
elif (( $(echo "$price > 10000" | bc -l) )); then |
|||
printf "%'0.0f\n" "$price" |
|||
else |
|||
printf "%0.2f\n" $price |
|||
fi |
|||
fi |
|||
done |
Write
Preview
Loading…
Cancel
Save
Reference in new issue