summaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
authorYigit Sever2021-11-04 12:25:04 +0300
committerYigit Sever2021-11-04 12:25:04 +0300
commita0bb023d782dd2d8703670d560b5ccd8d25d640e (patch)
tree1c11a649e2201e1458c4011894086f49da5ded15 /.local
parent93cdb13eada4e803fb4db71fb581d9e4a03d2119 (diff)
downloaddotfiles-a0bb023d782dd2d8703670d560b5ccd8d25d640e.tar.gz
dotfiles-a0bb023d782dd2d8703670d560b5ccd8d25d640e.tar.bz2
dotfiles-a0bb023d782dd2d8703670d560b5ccd8d25d640e.zip
bins: shfmt, weasel suite, spark
diffstat (limited to '.local')
-rwxr-xr-x.local/bin/bukuadd_c4
-rwxr-xr-x.local/bin/done4
-rwxr-xr-x.local/bin/dups54
-rwxr-xr-x.local/bin/epub_lander1
-rwxr-xr-x.local/bin/i3-get-window-criteria8
-rwxr-xr-x.local/bin/letsread2
-rwxr-xr-x.local/bin/mailsync32
-rwxr-xr-x.local/bin/mailto_handler2
-rwxr-xr-x.local/bin/openfile4
-rwxr-xr-x.local/bin/passive65
-rwxr-xr-x.local/bin/power.sh8
-rwxr-xr-x.local/bin/rfv12
-rwxr-xr-x.local/bin/spark103
-rwxr-xr-x.local/bin/texclear6
-rwxr-xr-x.local/bin/type.sh12
-rwxr-xr-x.local/bin/weasel38
16 files changed, 310 insertions, 45 deletions
diff --git a/.local/bin/bukuadd_c b/.local/bin/bukuadd_c
index 925022a..86f705d 100755
--- a/.local/bin/bukuadd_c
+++ b/.local/bin/bukuadd_c
@@ -10,7 +10,7 @@ fi
10 10
11FOO=$(buku --nostdin --np --nc -p -1) 11FOO=$(buku --nostdin --np --nc -p -1)
12OUT="$(buku --nostdin --np --nc -a "$url" "$tags" 2>&1)" 12OUT="$(buku --nostdin --np --nc -a "$url" "$tags" 2>&1)"
13if [[ $OUT =~ "ERROR" ]] ; then 13if [[ $OUT =~ "ERROR" ]]; then
14 notify-send "Bookmarking Failed" "$OUT" --app-name="buku" --icon="dialog-error" 14 notify-send "Bookmarking Failed" "$OUT" --app-name="buku" --icon="dialog-error"
15 exit 1 15 exit 1
16fi 16fi
@@ -20,7 +20,7 @@ BAR=$FOO
20while [[ $BAR == "$FOO" ]]; do 20while [[ $BAR == "$FOO" ]]; do
21 sleep 1 21 sleep 1
22 BAR=$(buku --nostdin --np --nc -p -1) 22 BAR=$(buku --nostdin --np --nc -p -1)
23done; 23done
24 24
25notify-send "Success" "$BAR" --app-name="buku" --icon="checkmark" 25notify-send "Success" "$BAR" --app-name="buku" --icon="checkmark"
26 26
diff --git a/.local/bin/done b/.local/bin/done
index 8bb0a3d..ae76287 100755
--- a/.local/bin/done
+++ b/.local/bin/done
@@ -27,9 +27,9 @@ if ACTIVE_TASK=$(task active); then
27 timew "@1" annotate "${annot:0:1}" 27 timew "@1" annotate "${annot:0:1}"
28 else 28 else
29 if maybe_delete=$(printf "no no\nyea" | rofi -dmenu -p "should we delete the tracking?" -lines 2 -no-custom); then 29 if maybe_delete=$(printf "no no\nyea" | rofi -dmenu -p "should we delete the tracking?" -lines 2 -no-custom); then
30 if [[ "${maybe_delete}" == "no no" ]]; then 30 if [[ ${maybe_delete} == "no no" ]]; then
31 notify-send "tracking unannotated, not deleted" "nobody will know how that went" --app-name="done" --icon="itmages-question" 31 notify-send "tracking unannotated, not deleted" "nobody will know how that went" --app-name="done" --icon="itmages-question"
32 elif [[ "${maybe_delete}" == "yea" ]]; then 32 elif [[ ${maybe_delete} == "yea" ]]; then
33 timew delete "@1" 33 timew delete "@1"
34 notify-send "tracking deleted" "like you never worked on that" --app-name="done" --icon="pack-more" 34 notify-send "tracking deleted" "like you never worked on that" --app-name="done" --icon="pack-more"
35 fi 35 fi
diff --git a/.local/bin/dups b/.local/bin/dups
new file mode 100755
index 0000000..eb450f5
--- /dev/null
+++ b/.local/bin/dups
@@ -0,0 +1,54 @@
1#!/usr/bin/env perl
2
3# Finds duplicate adjacent words.
4
5use strict ;
6
7my $DupCount = 0 ;
8
9if (!@ARGV) {
10 print "usage: dups <file> ...\n" ;
11 exit ;
12}
13
14while (1) {
15 my $FileName = shift @ARGV ;
16
17 # Exit code = number of duplicates found.
18 exit $DupCount if (!$FileName) ;
19
20 open FILE, $FileName or die $!;
21
22 my $LastWord = "" ;
23 my $LineNum = 0 ;
24
25 while (<FILE>) {
26 chomp ;
27
28 $LineNum ++ ;
29
30 my @words = split (/(\W+)/) ;
31
32 foreach my $word (@words) {
33 # Skip spaces:
34 next if $word =~ /^\s*$/ ;
35
36 # Skip punctuation:
37 if ($word =~ /^\W+$/) {
38 $LastWord = "" ;
39 next ;
40 }
41
42 # Found a dup?
43 if (lc($word) eq lc($LastWord)) {
44 print "$FileName:$LineNum $word\n" ;
45 $DupCount ++ ;
46 } # Thanks to Sean Cronin for tip on case.
47
48 # Mark this as the last word:
49 $LastWord = $word ;
50 }
51 }
52
53 close FILE ;
54}
diff --git a/.local/bin/epub_lander b/.local/bin/epub_lander
index 801381a..19e0a1c 100755
--- a/.local/bin/epub_lander
+++ b/.local/bin/epub_lander
@@ -15,4 +15,3 @@ mv $HOME/down/*.pdf $HOME/docs/pdf_landing/
15if [[ $? -ne 1 ]]; then 15if [[ $? -ne 1 ]]; then
16 notify-send "Moved some pdfs" "" --app-name="epub_lander" --icon="emblem_success" 16 notify-send "Moved some pdfs" "" --app-name="epub_lander" --icon="emblem_success"
17fi 17fi
18
diff --git a/.local/bin/i3-get-window-criteria b/.local/bin/i3-get-window-criteria
index f46f65e..6d6ea1b 100755
--- a/.local/bin/i3-get-window-criteria
+++ b/.local/bin/i3-get-window-criteria
@@ -9,7 +9,7 @@
9# quotes in "<string>" are not escaped properly. This is a problem with the output of `xprop`, 9# quotes in "<string>" are not escaped properly. This is a problem with the output of `xprop`,
10# reported upstream: https://bugs.freedesktop.org/show_bug.cgi?id=66807 10# reported upstream: https://bugs.freedesktop.org/show_bug.cgi?id=66807
11 11
12PROGNAME=`basename "$0"` 12PROGNAME=$(basename "$0")
13 13
14# Check for xwininfo and xprop 14# Check for xwininfo and xprop
15for cmd in xwininfo xprop; do 15for cmd in xwininfo xprop; do
@@ -25,13 +25,13 @@ match_qstring='"[^"\\]*(\\.[^"\\]*)*"' # NOTE: Adds 1 backreference
25 25
26{ 26{
27 # Run xwininfo, get window id 27 # Run xwininfo, get window id
28 window_id=`xwininfo -int | sed -nre "s/^xwininfo: Window id: ($match_int) .*$/\1/p"` 28 window_id=$(xwininfo -int | sed -nre "s/^xwininfo: Window id: ($match_int) .*$/\1/p")
29 echo "id=$window_id" 29 echo "id=$window_id"
30 30
31 # Run xprop, transform its output into i3 criteria. Handle fallback to 31 # Run xprop, transform its output into i3 criteria. Handle fallback to
32 # WM_NAME when _NET_WM_NAME isn't set 32 # WM_NAME when _NET_WM_NAME isn't set
33 xprop -id $window_id | 33 xprop -id $window_id \
34 sed -nr \ 34 | sed -nr \
35 -e "s/^WM_CLASS\(STRING\) = ($match_qstring), ($match_qstring)$/instance=\1\nclass=\3/p" \ 35 -e "s/^WM_CLASS\(STRING\) = ($match_qstring), ($match_qstring)$/instance=\1\nclass=\3/p" \
36 -e "s/^WM_WINDOW_ROLE\(STRING\) = ($match_qstring)$/window_role=\1/p" \ 36 -e "s/^WM_WINDOW_ROLE\(STRING\) = ($match_qstring)$/window_role=\1/p" \
37 -e "/^WM_NAME\(STRING\) = ($match_string)$/{s//title=\1/; h}" \ 37 -e "/^WM_NAME\(STRING\) = ($match_string)$/{s//title=\1/; h}" \
diff --git a/.local/bin/letsread b/.local/bin/letsread
index 5e3cf5a..d5f1e0c 100755
--- a/.local/bin/letsread
+++ b/.local/bin/letsread
@@ -1,4 +1,4 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2 2
3firefox $(buku --stag toread -f 10 | shuf -n 1) 3firefox "$(buku --stag toread -f 10 | shuf -n 1)"
4dunstify "Time to read" "Don't forget to remove 'toread' from that when you're done" 4dunstify "Time to read" "Don't forget to remove 'toread' from that when you're done"
diff --git a/.local/bin/mailsync b/.local/bin/mailsync
index ae0801c..cc7010b 100755
--- a/.local/bin/mailsync
+++ b/.local/bin/mailsync
@@ -3,9 +3,15 @@
3# Sync mail and give notification if there is new mail. 3# Sync mail and give notification if there is new mail.
4 4
5# Run only if user logged in (prevent cron errors) 5# Run only if user logged in (prevent cron errors)
6pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} 6pgrep -u "${USER:=$LOGNAME}" > /dev/null || {
7 echo "$USER not logged in; sync will not run."
8 exit
9}
7# Run only if not already running in other instance 10# Run only if not already running in other instance
8pgrep -x mbsync >/dev/null && { notify-send --app-name="mailsync" "mbsync is already running" "you should fix this" ; exit ;} 11pgrep -x mbsync > /dev/null && {
12 notify-send --app-name="mailsync" "mbsync is already running" "you should fix this"
13 exit
14}
9 15
10if [[ -f "$HOME/.local/share/.dnd" ]]; then 16if [[ -f "$HOME/.local/share/.dnd" ]]; then
11 echo "do not disturb is on" 17 echo "do not disturb is on"
@@ -13,8 +19,11 @@ if [[ -f "$HOME/.local/share/.dnd" ]]; then
13fi 19fi
14 20
15# Checks for internet connection and set notification script. 21# Checks for internet connection and set notification script.
16ping -q -c 1 1.1.1.1 > /dev/null || ping -q -c 1 1.0.0.1 > /dev/null || ping -q -c 1 example.org || { echo "No internet connection detected."; exit ;} 22ping -q -c 1 1.1.1.1 > /dev/null || ping -q -c 1 1.0.0.1 > /dev/null || ping -q -c 1 example.org || {
17command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script." 23 echo "No internet connection detected."
24 exit
25}
26command -v notify-send > /dev/null || echo 'Note that `libnotify` or `libnotify-send` should be installed for pop-up mail notifications with this script.'
18 27
19# Required to display notifications if run as a cronjob: 28# Required to display notifications if run as a cronjob:
20export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus 29export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
@@ -25,11 +34,11 @@ export DISPLAY=:0.0
25 34
26# Settings are different for MacOS (Darwin) systems. 35# Settings are different for MacOS (Darwin) systems.
27if [ "$(uname)" = "Darwin" ]; then 36if [ "$(uname)" = "Darwin" ]; then
28 notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} 37 notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2; }
29 messageinfo() { osascript -e "display notification with title \"πŸ“§ $from\" subtitle \"$subject\"" ;} 38 messageinfo() { osascript -e "display notification with title \"πŸ“§ $from\" subtitle \"$subject\""; }
30else 39else
31 notify() { notify-send --icon="mail_new" --app-name="excerpt" "\`$1\`" "πŸ“¬ $2 new mail(s)" ;} 40 notify() { notify-send --icon="mail_new" --app-name="excerpt" "\`$1\`" "πŸ“¬ $2 new mail(s)"; }
32 messageinfo() { notify-send --icon="mail-mark-unread" --app-name="mutt" "πŸ“§ $from" "$subject" ;} 41 messageinfo() { notify-send --icon="mail-mark-unread" --app-name="mutt" "πŸ“§ $from" "$subject"; }
33fi 42fi
34 43
35# Check account for new mail. Notify if there is new content. 44# Check account for new mail. Notify if there is new content.
@@ -44,7 +53,7 @@ syncandnotify() {
44 # Extract subject and sender from mail. 53 # Extract subject and sender from mail.
45 from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//') 54 from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
46 subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n') 55 subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
47 messageinfo & 56 messageinfo &
48 done 57 done
49 fi 58 fi
50} 59}
@@ -62,15 +71,14 @@ fi
62# ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null 71# ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null
63 72
64# Parallelize multiple accounts 73# Parallelize multiple accounts
65for account in $accounts 74for account in $accounts; do
66do
67 syncandnotify & 75 syncandnotify &
68done 76done
69 77
70wait 78wait
71# ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null 79# ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null
72 80
73notmuch new 2>/dev/null 81notmuch new 2> /dev/null
74 82
75#Create a touch file that indicates the time of the last run of mailsync 83#Create a touch file that indicates the time of the last run of mailsync
76touch "$HOME/.config/mutt/.mailsynclastrun" 84touch "$HOME/.config/mutt/.mailsynclastrun"
diff --git a/.local/bin/mailto_handler b/.local/bin/mailto_handler
index 9493558..36c38bd 100755
--- a/.local/bin/mailto_handler
+++ b/.local/bin/mailto_handler
@@ -21,6 +21,6 @@ for account in "${ACCOUNTSDIR}"/*.muttrc; do
21 21
22done 22done
23 23
24picked=$(printf "${choices}" | rofi -dmenu) 24picked=$(printf '%s' "${choices}" | rofi -dmenu)
25 25
26exec kitty -e neomutt -F "$HOME/.config/mutt/muttrc" -e "source /home/yigit/.config/mutt/accounts/${picked}.muttrc" -- "$@" 26exec kitty -e neomutt -F "$HOME/.config/mutt/muttrc" -e "source /home/yigit/.config/mutt/accounts/${picked}.muttrc" -- "$@"
diff --git a/.local/bin/openfile b/.local/bin/openfile
index cf3c6c3..742b9c0 100755
--- a/.local/bin/openfile
+++ b/.local/bin/openfile
@@ -1,10 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Helps open a file with xdg-open from mutt in a external program without weird side effects. 3# Helps open a file with xdg-open from mutt in a external program without weird side effects.
4tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files" 4tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt/files"
5file="$tempdir/$(basename "$1")" 5file="$tempdir/$(basename "$1")"
6[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open" 6[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open"
7mkdir -p "$tempdir" 7mkdir -p "$tempdir"
8cp -f "$1" "$file" 8cp -f "$1" "$file"
9$opener "$file" >/dev/null 2>&1 9$opener "$file" > /dev/null 2>&1
10find "${tempdir:?}" -mtime +1 -type f -delete 10find "${tempdir:?}" -mtime +1 -type f -delete
diff --git a/.local/bin/passive b/.local/bin/passive
new file mode 100755
index 0000000..276d61b
--- /dev/null
+++ b/.local/bin/passive
@@ -0,0 +1,65 @@
1#!/usr/bin/env bash
2
3irregulars="awoken|\
4 been|born|beat|\
5 become|begun|bent|\
6 beset|bet|bid|\
7 bidden|bound|bitten|\
8 bled|blown|broken|\
9 bred|brought|broadcast|\
10 built|burnt|burst|\
11 bought|cast|caught|\
12 chosen|clung|come|\
13 cost|crept|cut|\
14 dealt|dug|dived|\
15done|drawn|dreamt|\
16driven|drunk|eaten|fallen|\
17fed|felt|fought|found|\
18fit|fled|flung|flown|\
19forbidden|forgotten|\
20foregone|forgiven|\
21forsaken|frozen|\
22gotten|given|gone|\
23ground|grown|hung|\
24heard|hidden|hit|\
25held|hurt|kept|knelt|\
26knit|known|laid|led|\
27leapt|learnt|left|\
28lent|let|lain|lighted|\
29lost|made|meant|met|\
30misspelt|mistaken|mown|\
31overcome|overdone|overtaken|\
32overthrown|paid|pled|proven|\
33put|quit|read|rid|ridden|\
34rung|risen|run|sawn|said|\
35seen|sought|sold|sent|\
36set|sewn|shaken|shaven|\
37shorn|shed|shone|shod|\
38shot|shown|shrunk|shut|\
39sung|sunk|sat|slept|\
40slain|slid|slung|slit|\
41smitten|sown|spoken|sped|\
42spent|spilt|spun|spit|\
43split|spread|sprung|stood|\
44stolen|stuck|stung|stunk|\
45stridden|struck|strung|\
46striven|sworn|swept|\
47swollen|swum|swung|taken|\
48taught|torn|told|thought|\
49thrived|thrown|thrust|\
50trodden|understood|upheld|\
51upset|woken|worn|woven|\
52wed|wept|wound|won|\
53withheld|withstood|wrung|\
54written"
55
56if [ "$1" = "" ]; then
57 echo "usage: $(basename "$0") <file> ..."
58 exit
59fi
60
61grep -E -n -i --color \
62 "\\b(am|are|were|being|is|been|was|be)\
63 \\b[ ]*(\w+ed|($irregulars))\\b" "$*"
64
65exit $?
diff --git a/.local/bin/power.sh b/.local/bin/power.sh
index f794211..2dd7e5d 100755
--- a/.local/bin/power.sh
+++ b/.local/bin/power.sh
@@ -15,10 +15,10 @@ chosen=$(echo -e "lock\nshutdown\nrestart" | rofi -dmenu -i)
15# Info about some states are available here: 15# Info about some states are available here:
16# https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#Description 16# https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#Description
17 17
18if [[ $chosen = "lock" ]]; then 18if [[ $chosen == "lock" ]]; then
19 $HOME/.local/bin/lock 19 "$HOME"/.local/bin/lock
20elif [[ $chosen = "shutdown" ]]; then 20elif [[ $chosen == "shutdown" ]]; then
21 systemctl poweroff 21 systemctl poweroff
22elif [[ $chosen = "restart" ]]; then 22elif [[ $chosen == "restart" ]]; then
23 systemctl reboot 23 systemctl reboot
24fi 24fi
diff --git a/.local/bin/rfv b/.local/bin/rfv
index 4c9a632..a178e67 100755
--- a/.local/bin/rfv
+++ b/.local/bin/rfv
@@ -4,11 +4,11 @@
4# 2. Interactively narrow down the list using fzf 4# 2. Interactively narrow down the list using fzf
5# 3. Open the file in Vim 5# 3. Open the file in Vim
6IFS=: read -ra selected < <( 6IFS=: read -ra selected < <(
7 rg --color=always --line-number --no-heading --smart-case "${*:-}" | 7 rg --color=always --line-number --no-heading --smart-case "${*:-}" \
8 fzf --ansi \ 8 | fzf --ansi \
9 --color "hl:-1:underline,hl+:-1:underline:reverse" \ 9 --color "hl:-1:underline,hl+:-1:underline:reverse" \
10 --delimiter : \ 10 --delimiter : \
11 --preview 'bat --color=always {1} --highlight-line {2}' \ 11 --preview 'bat --color=always {1} --highlight-line {2}' \
12 --preview-window='up:60%:+{2}+3/3:~3' 12 --preview-window='up:60%:+{2}+3/3:~3'
13) 13)
14[ -n "${selected[0]}" ] && nvim "${selected[0]}" "+${selected[1]}" 14[ -n "${selected[0]}" ] && nvim "${selected[0]}" "+${selected[1]}"
diff --git a/.local/bin/spark b/.local/bin/spark
new file mode 100755
index 0000000..53a38be
--- /dev/null
+++ b/.local/bin/spark
@@ -0,0 +1,103 @@
1#!/usr/bin/env bash
2#
3# spark
4# https://github.com/holman/spark
5#
6# Generates sparklines for a set of data.
7#
8# Here's a good web-based sparkline generator that was a bit of inspiration
9# for spark:
10#
11# https://datacollective.org/sparkblocks
12#
13# spark takes a comma-separated or space-separated list of data and then prints
14# a sparkline out of it.
15#
16# Examples:
17#
18# spark 1 5 22 13 53
19# # => ▁▁▃▂▇
20#
21# spark 0 30 55 80 33 150
22# # => ▁▂▃▅▂▇
23#
24# spark -h
25# # => Prints the spark help text.
26
27# Generates sparklines.
28#
29# $1 - The data we'd like to graph.
30_echo()
31{
32 if [ "X$1" = "X-n" ]; then
33 shift
34 printf "%s" "$*"
35 else
36 printf "%s\n" "$*"
37 fi
38}
39
40spark()
41{
42 local n numbers=
43
44 # find min/max values
45 local min=0xffffffff max=0
46
47 for n in ${@//,/ }
48 do
49 # on Linux (or with bash4) we could use `printf %.0f $n` here to
50 # round the number but that doesn't work on OS X (bash3) nor does
51 # `awk '{printf "%.0f",$1}' <<< $n` work, so just cut it off
52 n=${n%.*}
53 (( n < min )) && min=$n
54 (( n > max )) && max=$n
55 numbers=$numbers${numbers:+ }$n
56 done
57
58 # print ticks
59 local ticks=(▁ β–‚ β–ƒ β–„ β–… β–† β–‡ β–ˆ)
60
61 # use a high tick if data is constant
62 (( min == max )) && ticks=(β–… β–†)
63
64 local f=$(( (($max-$min)<<8)/(${#ticks[@]}-1) ))
65 (( f < 1 )) && f=1
66
67 for n in $numbers
68 do
69 _echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
70 done
71 _echo
72}
73
74# If we're being sourced, don't worry about such things
75if [ "$BASH_SOURCE" == "$0" ]; then
76 # Prints the help text for spark.
77 help()
78 {
79 local spark=$(basename $0)
80 cat <<EOF
81
82 USAGE:
83 $spark [-h|--help] VALUE,...
84
85 EXAMPLES:
86 $spark 1 5 22 13 53
87 β–β–β–ƒβ–‚β–ˆ
88 $spark 0,30,55,80,33,150
89 β–β–‚β–ƒβ–„β–‚β–ˆ
90 echo 9 13 5 17 1 | $spark
91 β–„β–†β–‚β–ˆβ–
92EOF
93 }
94
95 # show help for no arguments if stdin is a terminal
96 if { [ -z "$1" ] && [ -t 0 ] ; } || [ "$1" == '-h' ] || [ "$1" == '--help' ]
97 then
98 help
99 exit 0
100 fi
101
102 spark ${@:-`cat`}
103fi
diff --git a/.local/bin/texclear b/.local/bin/texclear
index 9a32d70..1fb280a 100755
--- a/.local/bin/texclear
+++ b/.local/bin/texclear
@@ -8,7 +8,7 @@ case "$1" in
8 file=$(readlink -f "$1") 8 file=$(readlink -f "$1")
9 dir=$(dirname "$file") 9 dir=$(dirname "$file")
10 base="${file%.*}" 10 base="${file%.*}"
11 find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;; 11 find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete
12 *) printf "Give .tex file as argument.\\n" ;; 12 ;;
13 *) printf 'Give .tex file as argument.\n' ;;
13esac 14esac
14
diff --git a/.local/bin/type.sh b/.local/bin/type.sh
index b9dbcd7..2d563f3 100755
--- a/.local/bin/type.sh
+++ b/.local/bin/type.sh
@@ -1,15 +1,13 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2sleep 1 2sleep 1
3while read line 3while read -r line; do
4do 4 grep -o . <<< "$line" | while read -r a; do
5 grep -o . <<<$line | while read a 5 sleep 0.$((RANDOM % 3))
6 do
7 sleep 0.$((RANDOM%3))
8 #2>&1 echo -n "${a:- }" | tee /dev/tty 6 #2>&1 echo -n "${a:- }" | tee /dev/tty
9 echo -n "${a:- }" | tee /dev/tty 7 echo -n "${a:- }" | tee /dev/tty
10 done 8 done
11 sleep 0.$((RANDOM%7)) 9 sleep 0.$((RANDOM % 7))
12 1>&2 echo -ne $"\n" 10 echo 1>&2 -ne $"\n"
13 echo 11 echo
14 sleep 1.0 12 sleep 1.0
15done 13done
diff --git a/.local/bin/weasel b/.local/bin/weasel
new file mode 100755
index 0000000..ce82ce3
--- /dev/null
+++ b/.local/bin/weasel
@@ -0,0 +1,38 @@
1#!/usr/bin/env bash
2
3weasels="many|various|very|fairly|several|extremely\
4 |exceedingly|quite|remarkably|few|surprisingly\
5 |mostly|largely|huge|tiny|((are|is) a number)\
6 |excellent|interestingly|significantly\
7 |substantially|clearly|vast|relatively|completely"
8
9wordfile=""
10
11# Check for an alternate weasel file
12if [ -f "$HOME"/etc/words/weasels ]; then
13 wordfile="$HOME/etc/words/weasels"
14fi
15
16if [ -f "$WORDSDIR"/weasels ]; then
17 wordfile="$WORDSDIR/weasels"
18fi
19
20if [ -f words/weasels ]; then
21 wordfile="words/weasels"
22fi
23
24if [ ! "$wordfile" = "" ]; then
25 weasels="xyzabc123"
26 for w in $(cat $wordfile); do
27 weasels="$weasels|$w"
28 done
29fi
30
31if [ "$1" = "" ]; then
32 echo "usage: $(basename "$0") <file> ..."
33 exit
34fi
35
36grep -E -i -n --color "\\b($weasels)\\b" "$*"
37
38exit $?