-
Notifications
You must be signed in to change notification settings - Fork 8
/
pvim
executable file
·68 lines (60 loc) · 1.55 KB
/
pvim
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
64
65
66
67
68
#!/bin/sh
# pvim (Bourne shell script) -- captures standard input & edits it with vim
#
# Usage: pvim [ -t ] [ -d ] [ -r | -g ] [ <file_name> ]
#
# pvim prompts for a file name (if <file_name> was not specified) then copies
# standard input into it and edits it with vim. If <file_name> was prompted
# for, or if the -t option was specified, then the file will be created in
# public-html/frames/humour/text and be made world-readable.
# Other options:
# -d Make a temporary file and delete it after vim quits
# -r Make the file world-readable
# -g Like -r, but makes the file group-writeable as well
if [ "x$1" = "x-g" ] ; then
shift
readable_=
fi
if [ "x$1" = "x-r" ] ; then
shift
readable=
fi
if [ "x$1" = "x-t" ] ; then
shift
in_text=
fi
if [ "x$1" = "x-d" ] ; then
shift
name=/tmp/pvim.$USER.$$
in_tmp=
elif [ "$1" = "" ] ; then
echo -n "What do you want to call it? public-html/frames/humour/text/"
read name < /dev/tty
in_text=
else
name="$1"
fi
if [ -z "${in_text-not_set}" ] ; then
name="$HOME/public-html/frames/humour/text/$name"
readable=
fi
if [ -z "${in_text-not_set}" -a -f $name ] ; then
echo "But Wilbur, $name already exists!!" >&2
sleep 2
else
if [ -z "${in_tmp-not_set}" -a $VISUAL = vim ] ; then
vim +':set nomodified' -
else
cat > "$name"
if [ -z "${readable-not_set}" ] ; then
chmod 644 "$name"
elif [ -z "${readable_-not_set}" ] ; then
chmod 664 "$name"
fi
exec < /dev/tty
$VISUAL "$name"
if [ -z "${in_tmp-not_set}" ] ; then
rm "$name"
fi
fi
fi