diff options
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/bukuadd_c | 4 | ||||
-rwxr-xr-x | .local/bin/done | 4 | ||||
-rwxr-xr-x | .local/bin/dups | 54 | ||||
-rwxr-xr-x | .local/bin/epub_lander | 1 | ||||
-rwxr-xr-x | .local/bin/i3-get-window-criteria | 8 | ||||
-rwxr-xr-x | .local/bin/letsread | 2 | ||||
-rwxr-xr-x | .local/bin/mailsync | 32 | ||||
-rwxr-xr-x | .local/bin/mailto_handler | 2 | ||||
-rwxr-xr-x | .local/bin/openfile | 4 | ||||
-rwxr-xr-x | .local/bin/passive | 65 | ||||
-rwxr-xr-x | .local/bin/power.sh | 8 | ||||
-rwxr-xr-x | .local/bin/rfv | 12 | ||||
-rwxr-xr-x | .local/bin/spark | 103 | ||||
-rwxr-xr-x | .local/bin/texclear | 6 | ||||
-rwxr-xr-x | .local/bin/type.sh | 12 | ||||
-rwxr-xr-x | .local/bin/weasel | 38 |
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 | ||
11 | FOO=$(buku --nostdin --np --nc -p -1) | 11 | FOO=$(buku --nostdin --np --nc -p -1) |
12 | OUT="$(buku --nostdin --np --nc -a "$url" "$tags" 2>&1)" | 12 | OUT="$(buku --nostdin --np --nc -a "$url" "$tags" 2>&1)" |
13 | if [[ $OUT =~ "ERROR" ]] ; then | 13 | if [[ $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 |
16 | fi | 16 | fi |
@@ -20,7 +20,7 @@ BAR=$FOO | |||
20 | while [[ $BAR == "$FOO" ]]; do | 20 | while [[ $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) |
23 | done; | 23 | done |
24 | 24 | ||
25 | notify-send "Success" "$BAR" --app-name="buku" --icon="checkmark" | 25 | notify-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 | |||
5 | use strict ; | ||
6 | |||
7 | my $DupCount = 0 ; | ||
8 | |||
9 | if (!@ARGV) { | ||
10 | print "usage: dups <file> ...\n" ; | ||
11 | exit ; | ||
12 | } | ||
13 | |||
14 | while (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/ | |||
15 | if [[ $? -ne 1 ]]; then | 15 | if [[ $? -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" |
17 | fi | 17 | fi |
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 | ||
12 | PROGNAME=`basename "$0"` | 12 | PROGNAME=$(basename "$0") |
13 | 13 | ||
14 | # Check for xwininfo and xprop | 14 | # Check for xwininfo and xprop |
15 | for cmd in xwininfo xprop; do | 15 | for 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 | ||
3 | firefox $(buku --stag toread -f 10 | shuf -n 1) | 3 | firefox "$(buku --stag toread -f 10 | shuf -n 1)" |
4 | dunstify "Time to read" "Don't forget to remove 'toread' from that when you're done" | 4 | dunstify "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) |
6 | pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} | 6 | pgrep -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 |
8 | pgrep -x mbsync >/dev/null && { notify-send --app-name="mailsync" "mbsync is already running" "you should fix this" ; exit ;} | 11 | pgrep -x mbsync > /dev/null && { |
12 | notify-send --app-name="mailsync" "mbsync is already running" "you should fix this" | ||
13 | exit | ||
14 | } | ||
9 | 15 | ||
10 | if [[ -f "$HOME/.local/share/.dnd" ]]; then | 16 | if [[ -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 | |||
13 | fi | 19 | fi |
14 | 20 | ||
15 | # Checks for internet connection and set notification script. | 21 | # Checks for internet connection and set notification script. |
16 | ping -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 ;} | 22 | ping -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 || { |
17 | command -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 | } | ||
26 | command -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: |
20 | export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus | 29 | export 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. |
27 | if [ "$(uname)" = "Darwin" ]; then | 36 | if [ "$(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\""; } |
30 | else | 39 | else |
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"; } |
33 | fi | 42 | fi |
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 |
65 | for account in $accounts | 74 | for account in $accounts; do |
66 | do | ||
67 | syncandnotify & | 75 | syncandnotify & |
68 | done | 76 | done |
69 | 77 | ||
70 | wait | 78 | wait |
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 | ||
73 | notmuch new 2>/dev/null | 81 | notmuch 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 |
76 | touch "$HOME/.config/mutt/.mailsynclastrun" | 84 | touch "$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 | ||
22 | done | 22 | done |
23 | 23 | ||
24 | picked=$(printf "${choices}" | rofi -dmenu) | 24 | picked=$(printf '%s' "${choices}" | rofi -dmenu) |
25 | 25 | ||
26 | exec kitty -e neomutt -F "$HOME/.config/mutt/muttrc" -e "source /home/yigit/.config/mutt/accounts/${picked}.muttrc" -- "$@" | 26 | exec 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. |
4 | tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files" | 4 | tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt/files" |
5 | file="$tempdir/$(basename "$1")" | 5 | file="$tempdir/$(basename "$1")" |
6 | [ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open" | 6 | [ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open" |
7 | mkdir -p "$tempdir" | 7 | mkdir -p "$tempdir" |
8 | cp -f "$1" "$file" | 8 | cp -f "$1" "$file" |
9 | $opener "$file" >/dev/null 2>&1 | 9 | $opener "$file" > /dev/null 2>&1 |
10 | find "${tempdir:?}" -mtime +1 -type f -delete | 10 | find "${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 | |||
3 | irregulars="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|\ | ||
15 | done|drawn|dreamt|\ | ||
16 | driven|drunk|eaten|fallen|\ | ||
17 | fed|felt|fought|found|\ | ||
18 | fit|fled|flung|flown|\ | ||
19 | forbidden|forgotten|\ | ||
20 | foregone|forgiven|\ | ||
21 | forsaken|frozen|\ | ||
22 | gotten|given|gone|\ | ||
23 | ground|grown|hung|\ | ||
24 | heard|hidden|hit|\ | ||
25 | held|hurt|kept|knelt|\ | ||
26 | knit|known|laid|led|\ | ||
27 | leapt|learnt|left|\ | ||
28 | lent|let|lain|lighted|\ | ||
29 | lost|made|meant|met|\ | ||
30 | misspelt|mistaken|mown|\ | ||
31 | overcome|overdone|overtaken|\ | ||
32 | overthrown|paid|pled|proven|\ | ||
33 | put|quit|read|rid|ridden|\ | ||
34 | rung|risen|run|sawn|said|\ | ||
35 | seen|sought|sold|sent|\ | ||
36 | set|sewn|shaken|shaven|\ | ||
37 | shorn|shed|shone|shod|\ | ||
38 | shot|shown|shrunk|shut|\ | ||
39 | sung|sunk|sat|slept|\ | ||
40 | slain|slid|slung|slit|\ | ||
41 | smitten|sown|spoken|sped|\ | ||
42 | spent|spilt|spun|spit|\ | ||
43 | split|spread|sprung|stood|\ | ||
44 | stolen|stuck|stung|stunk|\ | ||
45 | stridden|struck|strung|\ | ||
46 | striven|sworn|swept|\ | ||
47 | swollen|swum|swung|taken|\ | ||
48 | taught|torn|told|thought|\ | ||
49 | thrived|thrown|thrust|\ | ||
50 | trodden|understood|upheld|\ | ||
51 | upset|woken|worn|woven|\ | ||
52 | wed|wept|wound|won|\ | ||
53 | withheld|withstood|wrung|\ | ||
54 | written" | ||
55 | |||
56 | if [ "$1" = "" ]; then | ||
57 | echo "usage: $(basename "$0") <file> ..." | ||
58 | exit | ||
59 | fi | ||
60 | |||
61 | grep -E -n -i --color \ | ||
62 | "\\b(am|are|were|being|is|been|was|be)\ | ||
63 | \\b[ ]*(\w+ed|($irregulars))\\b" "$*" | ||
64 | |||
65 | exit $? | ||
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 | ||
18 | if [[ $chosen = "lock" ]]; then | 18 | if [[ $chosen == "lock" ]]; then |
19 | $HOME/.local/bin/lock | 19 | "$HOME"/.local/bin/lock |
20 | elif [[ $chosen = "shutdown" ]]; then | 20 | elif [[ $chosen == "shutdown" ]]; then |
21 | systemctl poweroff | 21 | systemctl poweroff |
22 | elif [[ $chosen = "restart" ]]; then | 22 | elif [[ $chosen == "restart" ]]; then |
23 | systemctl reboot | 23 | systemctl reboot |
24 | fi | 24 | fi |
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 |
6 | IFS=: read -ra selected < <( | 6 | IFS=: 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 | |||
40 | spark() | ||
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 | ||
75 | if [ "$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 | ▄▆▂█▁ | ||
92 | EOF | ||
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`} | ||
103 | fi | ||
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' ;; | ||
13 | esac | 14 | esac |
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 |
2 | sleep 1 | 2 | sleep 1 |
3 | while read line | 3 | while read -r line; do |
4 | do | 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 |
15 | done | 13 | done |
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 | |||
3 | weasels="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 | |||
9 | wordfile="" | ||
10 | |||
11 | # Check for an alternate weasel file | ||
12 | if [ -f "$HOME"/etc/words/weasels ]; then | ||
13 | wordfile="$HOME/etc/words/weasels" | ||
14 | fi | ||
15 | |||
16 | if [ -f "$WORDSDIR"/weasels ]; then | ||
17 | wordfile="$WORDSDIR/weasels" | ||
18 | fi | ||
19 | |||
20 | if [ -f words/weasels ]; then | ||
21 | wordfile="words/weasels" | ||
22 | fi | ||
23 | |||
24 | if [ ! "$wordfile" = "" ]; then | ||
25 | weasels="xyzabc123" | ||
26 | for w in $(cat $wordfile); do | ||
27 | weasels="$weasels|$w" | ||
28 | done | ||
29 | fi | ||
30 | |||
31 | if [ "$1" = "" ]; then | ||
32 | echo "usage: $(basename "$0") <file> ..." | ||
33 | exit | ||
34 | fi | ||
35 | |||
36 | grep -E -i -n --color "\\b($weasels)\\b" "$*" | ||
37 | |||
38 | exit $? | ||