Debian Codegraph @

source/util/edit_vault

raw
1 #!/bin/sh
2 # You probably want to stick the following into your .bash_profile:
3 # alias ev=~/crawl/crawl-ref/source/util/edit_vault
4 #
5 # You need to define $EDITOR as well; on Debian there's some weak-ass
6 # autodetection but that's unlikely to match _your_ preferences. And it
7 # may start something as vile as vi.
8
9
10 if [ -z "$1" ]
11 then
12 echo >&2 "Usage: edit-vault vault_name"
13 exit 1
14 fi
15
16 V=`grep -rHn --include='*.des' "NAME: *$1$"`
17 if [ -z "$V" ]
18 then
19 echo >&2 "Vault \"$1\" not found."
20 exit 1
21 fi
22
23 if which sensible-editor >/dev/null
24 then
25 ED=sensible-editor
26 else
27 ED="${EDITOR:-editor}"
28 fi
29
30 FILE="${V%%:*}"
31 LINE="${V#*:}"; LINE="${LINE%%:*}"
32
33 "$ED" +"$LINE" "$FILE"