-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscratch.sh
More file actions
executable file
·46 lines (38 loc) · 832 Bytes
/
scratch.sh
File metadata and controls
executable file
·46 lines (38 loc) · 832 Bytes
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
#! /bin/bash
set -e
SCRATCH=/tmp/scratch
[[ -d $SCRATCH_DIR ]] && SCRATCH=$SCRATCH_DIR
scratch_up () {
trap scratch_down EXIT
if [[ -d "${SCRATCH}" ]]; then
rm -rf ${SCRATCH}/*
else
mkdir ${SCRATCH}
fi
cd ${SCRATCH}
}
scratch_down () {
if [[ -z $KEEP_SCRATCH ]]; then
if [[ -d "${SCRATCH}" ]]; then
rm -rf ${SCRATCH}
fi
fi
}
clean_scratch () {
if [[ -z $KEEP_SCRATCH ]]; then
echo "KEEP_SCRATCH == $KEEP_SCRATCH" >&2
return 1
fi
[[ -d "${SCRATCH}" ]] && rm -rf ${SCRATCH}
mkdir ${SCRATCH}
}
scratch_copy () {
echo "" > $SCRATCH
/usr/local/bin/vim $SCRATCH
/bin/cat $SCRATCH | /usr/bin/pbcopy
}
scratch_paste () {
SCRATCH=$HOME/tmp/fred
/usr/bin/pbpaste > $SCRATCH
/usr/local/bin/vim $SCRATCH
}