-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
executable file
·63 lines (55 loc) · 1.16 KB
/
.functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# functions
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_"
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1
then
local arg=-sbh
else
local arg=-sh
fi
if [[ -n "$@" ]]
then
du $arg -- "$@"
else
du $arg .[^.]* *
fi
}
# Use Git’s colored diff when available
hash git &>/dev/null
if [ $? -eq 0 ]
then
function diff() {
git diff --no-index --color-words "$@"
}
fi
# Ghostscript functions
combinepdf () {
if [ $# -lt 2 ]
then
echo 'Usage: combinepdf File1.pdf File2.pdf'
echo 'Note : Output is written to file1.pdf. Other files are deleted'
exit
fi
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=tempcombinepdf.pdf \
$@
if [ -f tempcombinepdf.pdf ]
then
rm -rf $@
mv tempcombinepdf.pdf $1
fi
}
reducepdf () {
if [ $# -lt 2 ]
then
echo 'Usage: reducepdf input.pdf output.pdf'
exit
fi
gs -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dQUIET -dBATCH \
-dNOPAUSE -sDEVICE=pdfwrite \
-sOutputFile=$2 $1
}