summaryrefslogtreecommitdiff
path: root/dot
diff options
context:
space:
mode:
Diffstat (limited to 'dot')
-rw-r--r--dot/Xresources3
-rwxr-xr-xdot/local/bin/latest36
-rwxr-xr-xdot/local/bin/lpdf44
-rw-r--r--dot/local/bin/scan19
-rwxr-xr-xdot/local/bin/ssh-shellwrap19
5 files changed, 105 insertions, 16 deletions
diff --git a/dot/Xresources b/dot/Xresources
index 864d11a..0822b40 100644
--- a/dot/Xresources
+++ b/dot/Xresources
@@ -66,3 +66,6 @@ xboard*ponderNextMove: false
66 xpdf*urlCommand: "firefox '%s'" 66 xpdf*urlCommand: "firefox '%s'"
67 xpdf*background: black 67 xpdf*background: black
68xpdf*continuousView: true 68xpdf*continuousView: true
69
70! This fixes xterm rv mode in later Debians:
71*customization:
diff --git a/dot/local/bin/latest b/dot/local/bin/latest
index ef95cfe..12a0a9f 100755
--- a/dot/local/bin/latest
+++ b/dot/local/bin/latest
@@ -3,23 +3,45 @@ usage()
3{ 3{
4 cat <<EOF 4 cat <<EOF
5Usage: $0 [directory] [...] 5Usage: $0 [directory] [...]
6Usage: $0 --help
6 7
7Print the filename of the newest file. 8Searches the current directory if none is specified.
9
10Print one filename: the single newest ordinary file from all (not each)
11of the specified directories.
12
13If there are no ordinary files, there is no output.
14
15Symbolic links are not listed.
8 16
9Searches the directories specified on the command line,
10or else the current directory if none specified.
11EOF 17EOF
12} 18}
13 19
14case $# in 20case $# in
15 0) set -- . ;; 21 0) set -- . ;;
16 1) if [ "$1" = --usage ]; then usage; exit 0; fi ;; 22 1) if [ "$1" = --usage ]
23 then
24 usage
25 exit 0
26 fi
27 ;;
17esac 28esac
18 29
19extract() 30drop_first_word()
31{
32 sed -ne 's/^[^ ]* //p'
33}
34
35extract_newest()
36{
37 sort -z -n -k1,1 -r | head -z -n 1 | xargs -r -0 printf '%s\n'
38}
39
40find_simple_files()
20{ 41{
21 sort -z -n -k1,1 -r | head -z -n 1 | xargs -0 printf '%s\n' | perl -pe 's/.*? //' 42 pattern="%C@ %h/%f\0"
43 find "$@" -maxdepth 1 -name '.*' -o \( -type f -printf "$pattern" \)
22} 44}
23 45
24find "$@" -maxdepth 1 -name '.*' -o \( -type f -printf "%C@ %h/%f\0" \) | extract 46find_simple_files "$@" | extract_newest | drop_first_word
25 47
diff --git a/dot/local/bin/lpdf b/dot/local/bin/lpdf
new file mode 100755
index 0000000..41f52c4
--- /dev/null
+++ b/dot/local/bin/lpdf
@@ -0,0 +1,44 @@
1#!/bin/bash
2# lpdf -- print with lp to a PDF file; output the filename to stdout
3
4move_pdf()
5{
6 local o f="$1"
7 o=$f
8 o=${o##*/}
9 o=${o%%__*}
10 o=${o%.txt}.pdf
11 mv -i -T -- "$f" "$o"
12}
13
14run_lp()
15{
16 set -x
17 lp "$@" -d PDF
18}
19
20extract_lp_pdf_filename()
21{
22 read _ _ _ pdf _
23 case "$pdf" in
24 PDF-*) glob=$(printf "~/PDF/*-job_%s.pdf\n" "${pdf#PDF-}") ;;
25 *) exit 1 ;;
26 esac
27
28 sleep=1
29 while true
30 do
31 if f=$(shopt -s failglob; 2>/dev/null eval "echo $glob")
32 then
33 printf "%s\n" "$f"
34 break
35 else
36 sleep $sleep
37 sleep=$((sleep + 1))
38 fi
39 done
40}
41
42set -e
43read pdf < <(run_lp "$@" | extract_lp_pdf_filename)
44move_pdf "$pdf"
diff --git a/dot/local/bin/scan b/dot/local/bin/scan
index 2ba071b..2a7ac71 100644
--- a/dot/local/bin/scan
+++ b/dot/local/bin/scan
@@ -1,16 +1,17 @@
1#!/bin/sh 1#!/bin/sh
2NOW=$( TZ=UTC date -Ins | tr T . | tr -d : | sed -E 's/(..),(...).*/\1.\2/' ) 2NOW=$( TZ=UTC date -Ins | tr T . | tr -d : | sed -E 's/(..),(...).*/\1.\2/' )
3 3
4if [ $# = 0 ] 4if [ "$ACTUAL_BATCH" -a $# = 0 ]
5then 5then
6 ACTUAL_BATCH= 6 FORMAT=scan_${NOW}_%.3d.png
7fi
8
9if $ACTUAL_BATCH
10then
11 format=scan_${NOW}_%.3d.png
12else 7else
13 format=scan_${NOW}.png 8 FORMAT=scan_${NOW}.png
14fi 9fi
15 10
16scanimage --progress --format=png --batch="$format" 11RESOLUTION=600
12
13scanimage --progress \
14 --mode=Color \
15 --resolution="$RESOLUTION" \
16 --format=png \
17 --batch="$FORMAT"
diff --git a/dot/local/bin/ssh-shellwrap b/dot/local/bin/ssh-shellwrap
new file mode 100755
index 0000000..e0d537e
--- /dev/null
+++ b/dot/local/bin/ssh-shellwrap
@@ -0,0 +1,19 @@
1#!/bin/bash
2# ssh wrapper; requires "--" before host argument
3options=()
4while [ $# -gt 0 ]
5do
6 case $1 in
7 -- ) break ;;
8 esac
9 options+=("$1")
10 shift
11done
12set -e
13[ "$1" = '--' ]
14shift
15[ $# -gt 0 ]
16host=$1
17shift
18ssh "${options[@]}" -- "$host" ${*@Q}
19