aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-03-25 18:23:47 -0300
committerEuAndreh <eu@euandre.org>2022-03-25 18:23:47 -0300
commita0f6851577e6a2bc4ec835b8092a0b1304a6640c (patch)
tree4f85f94c4e94649563b6b615c987d9c794fc410a /src/bin
parentTODOs.md: Add #td-e2b2e9d5-b8c9-9ce3-a0c1-699963325d4e (diff)
downloaddotfiles-a0f6851577e6a2bc4ec835b8092a0b1304a6640c.tar.gz
dotfiles-a0f6851577e6a2bc4ec835b8092a0b1304a6640c.tar.xz
src/bin/print: Allow printing files from different directories
Diffstat (limited to 'src/bin')
-rwxr-xr-xsrc/bin/print22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/bin/print b/src/bin/print
index f6de2dce..735d8baa 100755
--- a/src/bin/print
+++ b/src/bin/print
@@ -47,16 +47,18 @@ n_pages() {
}
main() {
- if file -b in-tmp | grep -q PostScript; then
- ps2pdf in-tmp in.pdf
- elif file -b in-tmp | grep -q PDF; then
- cp in-tmp in.pdf
+ if file -b "$FILE" | grep -q PostScript; then
+ ps2pdf "$FILE" "$NEWDIR"/in.pdf
+ elif file -b "$FILE" | grep -q PDF; then
+ cp "$FILE" "$NEWDIR"/in.pdf
else
- enscript -o- in-tmp | ps2pdf - in.pdf
+ enscript -o- "$FILE" | ps2pdf - "$NEWDIR"/in.pdf
fi
+ cd "$NEWDIR"
if [ -z "$DUPLEX" ]; then
lp in.pdf
+ cd - > /dev/null
return
fi
@@ -80,6 +82,8 @@ main() {
if [ "$NODD" != "$NEVEN" ]; then
printf '\n' | lp
fi
+
+ cd - > /dev/null
}
for flag in "$@"; do
@@ -136,14 +140,12 @@ shift $((OPTIND - 1))
NEWDIR="$(mkdtemp)"
if [ -z "${1:-}" ]; then
- cd "$NEWDIR"
- cat - > in-tmp
+ FILE="$NEWDIR"/STDIN
+ cat - > "$FILE"
main
else
for f in "$@"; do
- cp "$f" "$NEWDIR"/in-tmp
- cd "$NEWDIR"
+ FILE="$f"
main
- cd - > /dev/null
done
fi